axle OS
x86_32 UNIX-like hobby OS
vbe.h
1 #ifndef VBE_H
2 #define VBE_H
3 
4 #include <stddef.h>
5 #include <stdint.h>
6 #include <stdbool.h>
7 
8 #define VBE_DISPI_IOPORT_INDEX 0x01CE
9 #define VBE_DISPI_IOPORT_DATA 0x01CF
10 #define VBE_DISPI_INDEX_ID 0
11 #define VBE_DISPI_INDEX_XRES 1
12 #define VBE_DISPI_INDEX_YRES 2
13 #define VBE_DISPI_INDEX_BPP 3
14 #define VBE_DISPI_INDEX_BANK 5
15 #define VBE_DISPI_INDEX_VIRT_WIDTH 6
16 #define VBE_DISPI_INDEX_VIRT_HEIGHT 7
17 #define VBE_DISPI_INDEX_X_OFFSET 8
18 #define VBE_DISPI_INDEX_Y_OFFSET 9
19 
20 #define VBE_DISPI_BPP_4 0x04
21 #define VBE_DISPI_BPP_8 0x08
22 #define VBE_DISPI_BPP_15 0x0F
23 #define VBE_DISPI_BPP_16 0x10
24 #define VBE_DISPI_BPP_24 0x18
25 #define VBE_DISPI_BPP_32 0x20
26 
27 #define VBE_DISPI_DISABLED 0x00
28 #define VBE_DISPI_ENABLED 0x01
29 #define VBE_DISPI_INDEX_ENABLE 0x04
30 #define VBE_DISPI_LFB_ENABLED 0x40
31 #define VBE_DISPI_NOCLEARMEM 0x80
32 
33 #define VBE_DISPI_ID0 0xB0C0
34 #define VBE_DISPI_ID1 0xB0C1
35 #define VBE_DISPI_ID2 0xB0C2
36 #define VBE_DISPI_ID3 0xB0C3
37 #define VBE_DISPI_ID4 0xB0C4
38 #define VBE_DISPI_ID5 0xB0C5
39 
40 #define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xA0000
41 #define BANK_SIZE 0x10000
42 
43 //typedef for VESA mode information
44 typedef struct vbe_mode_info {
45  unsigned short mode_attributes __attribute__((packed));
46  unsigned char win_a_attributes;
47  unsigned char win_b_attributes;
48  unsigned short win_granularity __attribute__((packed));
49  unsigned short win_size __attribute__((packed));
50  unsigned short win_a_segment __attribute__((packed));
51  unsigned short win_b_segment __attribute__((packed));
52  unsigned long win_func_ptr __attribute__((packed));
53  unsigned short bytes_per_scan_line __attribute__((packed));
54  unsigned short x_res __attribute__((packed));
55  unsigned short y_res __attribute__((packed));
56  unsigned char x_char_size;
57  unsigned char y_char_size;
58  unsigned char num_planes;
59  unsigned char bpp;
60  unsigned char bank_num;
61  unsigned char mem_model;
62  unsigned char bank_size;
63  unsigned char num_image_pages;
64  unsigned char reserved_page;
65  unsigned char red_mask_size;
66  unsigned char red_mask_pos;
67  unsigned char green_mask_size;
68  unsigned char green_mask_pos;
69  unsigned char blue_mask_size;
70  unsigned char blue_mask_pos;
71  unsigned char reserved_mask_size;
72  unsigned char reserved_mask_pos;
73  unsigned char direct_color_mode_info;
74  unsigned long physbase __attribute__((packed));
75  unsigned long offscreen_mem_offset __attribute__((packed));
76  unsigned short offscreen_mem_size __attribute__((packed));
77  unsigned char reserved[256];
79 
80 typedef struct vesa_info {
81  unsigned char vesa_signature[4];
82  unsigned short vesa_version __attribute__((packed));
83  unsigned long oem_string_ptr __attribute__((packed));
84  unsigned char capabilities[4];
85  unsigned long video_mode_ptr __attribute__((packed));
86  unsigned short total_memory __attribute__((packed));
87  unsigned short oem_software_rev __attribute__((packed));
88  unsigned long oem_vendor_name_ptr __attribute__((packed));
89  unsigned long oem_product_name_ptr __attribute__((packed));
90  unsigned long oem_product_rev_ptr __attribute__((packed));
91  unsigned char reserved[222];
92  unsigned char oem_data[256];
93 } vesa_info;
94 
95 //read/write to VBE registers
96 void vbe_write_reg(unsigned short idx, unsigned short val);
97 unsigned short vbe_read_reg(unsigned short idx);
98 
99 //is VBE available in our environment?
100 bool vbe_available(void);
101 
102 //switch video memory bank to 'bank_num'
103 void vbe_set_bank(unsigned short bank_num);
104 
105 //perform VBE graphics mode switch using given parameters
106 //if 'use_lfb' is set pixels can be plotted directly onto a framebuffer
107 //if 'clear_vmem' is set we'll request VBE clear framebuffer before we recieve it
108 void vbe_set_video_mode(unsigned int width, unsigned int height, unsigned int depth, bool use_lfb, bool clear_vmem);
109 
110 #endif
111 
Definition: elf.h:10
Definition: vbe.h:80
Definition: vbe.h:44