Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-int
-bochsvga_list_modes(u16 seg, u16 ptr)
+void
+bochsvga_list_modes(u16 seg, u16 *dest, u16 *last)
- int count = 0;
- u16 *dest = (u16 *)(u32)ptr;
-
struct bochsvga_mode *m = bochsvga_modes;
struct bochsvga_mode *m = bochsvga_modes;
- for (; m < &bochsvga_modes[ARRAY_SIZE(bochsvga_modes)]; m++) {
+ for (; m < &bochsvga_modes[ARRAY_SIZE(bochsvga_modes)] && dest<last; m++) {
if (!mode_valid(&m->info))
continue;
dprintf(1, "VBE found mode %x valid.\n", GET_GLOBAL(m->mode));
if (!mode_valid(&m->info))
continue;
dprintf(1, "VBE found mode %x valid.\n", GET_GLOBAL(m->mode));
- SET_FARVAR(seg, dest[count], GET_GLOBAL(m->mode));
-
- count++;
+ SET_FARVAR(seg, *dest, GET_GLOBAL(m->mode));
+ dest++;
- SET_FARVAR(seg, dest[count], 0xffff); /* End of list */
-
- return count;
+ stdvga_list_modes(seg, dest, last);
int bochsvga_init(void);
int bochsvga_enabled(void);
u16 bochsvga_total_mem(void);
int bochsvga_init(void);
int bochsvga_enabled(void);
u16 bochsvga_total_mem(void);
-int bochsvga_list_modes(u16 seg, u16 ptr);
+void bochsvga_list_modes(u16 seg, u16 *dest, u16 *last);
struct vbe_modeinfo;
int bochsvga_mode_info(u16 mode, struct vbe_modeinfo *info);
void bochsvga_hires_enable(int enable);
struct vbe_modeinfo;
int bochsvga_mode_info(u16 mode, struct vbe_modeinfo *info);
void bochsvga_hires_enable(int enable);
+void
+clext_list_modes(u16 seg, u16 *dest, u16 *last)
+{
+ int i;
+ for (i=0; i<ARRAY_SIZE(cirrus_vesa_modelist) && dest<last; i++) {
+ SET_FARVAR(seg, *dest, GET_GLOBAL(cirrus_vesa_modelist[i].vesamode));
+ dest++;
+ }
+ stdvga_list_modes(seg, dest, last);
+}
+
static u16
cirrus_vesamode_to_mode(u16 vesamode)
{
static u16
cirrus_vesamode_to_mode(u16 vesamode)
{
SET_FARVAR(seg, info->total_memory, cirrus_get_memsize());
u16 *destmode = (void*)info->reserved;
SET_FARVAR(seg, info->total_memory, cirrus_get_memsize());
u16 *destmode = (void*)info->reserved;
+ u16 *last = (void*)&info->reserved[sizeof(info->reserved)];
SET_FARVAR(seg, info->video_mode, SEGOFF(seg, (u32)destmode));
SET_FARVAR(seg, info->video_mode, SEGOFF(seg, (u32)destmode));
- int i;
- for (i=0; i<ARRAY_SIZE(cirrus_vesa_modelist); i++)
- SET_FARVAR(seg, destmode[i]
- , GET_GLOBAL(cirrus_vesa_modelist[i].vesamode));
- SET_FARVAR(seg, destmode[i], 0xffff);
+ clext_list_modes(seg, destmode, last);
struct vgamode_s *clext_find_mode(int mode);
int clext_set_mode(int mode, int flags);
struct vgamode_s *clext_find_mode(int mode);
int clext_set_mode(int mode, int flags);
+void clext_list_modes(u16 seg, u16 *dest, u16 *last);
int clext_init(void);
#endif // clext.h
int clext_init(void);
#endif // clext.h
* Misc
****************************************************************/
* Misc
****************************************************************/
+void
+stdvga_list_modes(u16 seg, u16 *dest, u16 *last)
+{
+ SET_FARVAR(seg, *dest, 0xffff);
+}
+
void
stdvga_enable_video_addressing(u8 disable)
{
void
stdvga_enable_video_addressing(u8 disable)
{
void stdvga_restore_state(u16 seg, struct saveVideoHardware *info);
int stdvga_set_mode(int mode, int flags);
void stdvga_enable_video_addressing(u8 disable);
void stdvga_restore_state(u16 seg, struct saveVideoHardware *info);
int stdvga_set_mode(int mode, int flags);
void stdvga_enable_video_addressing(u8 disable);
+void stdvga_list_modes(u16 seg, u16 *dest, u16 *last);
int stdvga_init(void);
#endif // stdvga.h
int stdvga_init(void);
#endif // stdvga.h
SET_FARVAR(seg, info->capabilities, 0x1); /* 8BIT DAC */
/* We generate our mode list in the reserved field of the info block */
SET_FARVAR(seg, info->capabilities, 0x1); /* 8BIT DAC */
/* We generate our mode list in the reserved field of the info block */
- SET_FARVAR(seg, info->video_mode, SEGOFF(seg, regs->di + 34));
+ u16 *destmode = (void*)info->reserved;
+ SET_FARVAR(seg, info->video_mode, SEGOFF(seg, (u32)destmode));
/* Total memory (in 64 blocks) */
SET_FARVAR(seg, info->total_memory, bochsvga_total_mem());
/* Total memory (in 64 blocks) */
SET_FARVAR(seg, info->total_memory, bochsvga_total_mem());
SEGOFF(get_global_seg(), (u32)VBE_REVISION_STRING));
/* Fill list of modes */
SEGOFF(get_global_seg(), (u32)VBE_REVISION_STRING));
/* Fill list of modes */
- bochsvga_list_modes(seg, regs->di + 32);
+ u16 *last = (void*)&info->reserved[sizeof(info->reserved)];
+ vgahw_list_modes(seg, destmode, last - 1);
regs->al = regs->ah; /* 0x4F, Function supported */
regs->ah = 0x0; /* 0x0, Function call successful */
regs->al = regs->ah; /* 0x4F, Function supported */
regs->ah = 0x0; /* 0x0, Function call successful */
return stdvga_set_mode(mode, flags);
}
return stdvga_set_mode(mode, flags);
}
+static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {
+ if (CONFIG_VGA_CIRRUS)
+ clext_list_modes(seg, dest, last);
+ else if (CONFIG_VGA_BOCHS)
+ bochsvga_list_modes(seg, dest, last);
+ else
+ stdvga_list_modes(seg, dest, last);
+}
+
static inline int vgahw_init(void) {
if (CONFIG_VGA_CIRRUS)
return clext_init();
static inline int vgahw_init(void) {
if (CONFIG_VGA_CIRRUS)
return clext_init();