1 #include "kvm/segment.h"
7 #define VESA_MAGIC ('V' + ('E' << 8) + ('S' << 16) + ('A' << 24))
9 /* VESA General Information table */
10 struct vesa_general_info
{
11 u32 signature
; /* 0 Magic number = "VESA" */
13 void *vendor_string
; /* 6 */
14 u32 capabilities
; /* 10 */
15 void *video_mode_ptr
; /* 14 */
16 u16 total_memory
; /* 18 */
17 u16 modes
[2]; /* 20 */
18 char oem_string
[11]; /* 24 */
20 u8 reserved
[223]; /* 35 */
21 } __attribute__ ((packed
));
24 u16 mode_attr
; /* 0 */
25 u8 win_attr
[2]; /* 2 */
26 u16 win_grain
; /* 4 */
28 u16 win_seg
[2]; /* 8 */
29 u32 win_scheme
; /* 12 */
30 u16 logical_scan
; /* 16 */
34 u8 char_width
; /* 22 */
35 u8 char_height
; /* 23 */
36 u8 memory_planes
; /* 24 */
39 u8 memory_layout
; /* 27 */
40 u8 bank_size
; /* 28 */
41 u8 image_planes
; /* 29 */
42 u8 page_function
; /* 30 */
50 u8 resv_mask
; /* 37 */
54 u32 lfb_ptr
; /* 40 Linear frame buffer address */
55 u32 offscreen_ptr
; /* 44 Offscreen memory address */
56 u16 offscreen_size
; /* 48 */
58 u8 reserved
[206]; /* 50 */
61 static inline void outb(unsigned short port
, unsigned char val
)
63 asm volatile("outb %0, %1" : : "a"(val
), "Nd"(port
));
67 * It's probably much more useful to make this print to the serial
68 * line rather than print to a non-displayed VGA memory
70 static inline void int10_putchar(struct biosregs
*args
)
72 u8 al
= args
->eax
& 0xFF;
77 static void vbe_get_mode(struct biosregs
*args
)
79 struct vminfo
*info
= (struct vminfo
*) args
->edi
;
81 *info
= (struct vminfo
) {
82 .mode_attr
= 0xd9, /* 11011011 */
83 .logical_scan
= VESA_WIDTH
*4,
89 .lfb_ptr
= VESA_MEM_ADDR
,
100 static void vbe_get_info(struct biosregs
*args
)
102 struct vesa_general_info
*info
= (struct vesa_general_info
*) args
->edi
;
104 *info
= (struct vesa_general_info
) {
105 .signature
= VESA_MAGIC
,
107 .vendor_string
= &info
->oem_string
,
108 .capabilities
= 0x10,
109 .video_mode_ptr
= &info
->modes
,
110 .total_memory
= (4 * VESA_WIDTH
* VESA_HEIGHT
) / 0x10000,
111 .oem_string
= "KVM VESA",
112 .modes
= { 0x0112, 0xffff },
116 #define VBE_STATUS_OK 0x004F
118 static void int10_vesa(struct biosregs
*args
)
122 al
= args
->eax
& 0xff;
133 args
->eax
= VBE_STATUS_OK
;
136 bioscall
void int10_handler(struct biosregs
*args
)
140 ah
= (args
->eax
& 0xff00) >> 8;