Kevin O'Connor | e1e000b | 2011-12-31 03:30:40 -0500 | [diff] [blame] | 1 | #ifndef __VGABIOS_H |
| 2 | #define __VGABIOS_H |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 3 | |
| 4 | #include "types.h" // u8 |
Kevin O'Connor | 9f98542 | 2009-09-09 11:34:39 -0400 | [diff] [blame] | 5 | #include "farptr.h" // struct segoff_s |
Kevin O'Connor | 6397790 | 2014-10-23 16:24:36 -0400 | [diff] [blame] | 6 | #include "std/vga.h" // struct video_param_s |
Kevin O'Connor | aad3b69 | 2012-01-14 23:15:40 -0500 | [diff] [blame] | 7 | |
Kevin O'Connor | 20dc419 | 2014-02-05 20:52:25 -0500 | [diff] [blame] | 8 | // Save/Restore flags |
| 9 | #define SR_HARDWARE 0x0001 |
| 10 | #define SR_BDA 0x0002 |
| 11 | #define SR_DAC 0x0004 |
| 12 | #define SR_REGISTERS 0x0008 |
| 13 | #define SR_SAVE 0x0100 |
| 14 | #define SR_RESTORE 0x0200 |
Kevin O'Connor | ca66864 | 2009-05-21 23:06:08 -0400 | [diff] [blame] | 15 | |
Kevin O'Connor | 821d6b4 | 2011-12-31 18:19:22 -0500 | [diff] [blame] | 16 | // Mode flags |
Kevin O'Connor | b7b9293 | 2013-03-09 13:04:47 -0500 | [diff] [blame] | 17 | #define MF_LEGACY 0x0001 |
Kevin O'Connor | 821d6b4 | 2011-12-31 18:19:22 -0500 | [diff] [blame] | 18 | #define MF_GRAYSUM 0x0002 |
| 19 | #define MF_NOPALETTE 0x0008 |
| 20 | #define MF_CUSTOMCRTC 0x0800 |
| 21 | #define MF_LINEARFB 0x4000 |
| 22 | #define MF_NOCLEARMEM 0x8000 |
Kevin O'Connor | e6bc4c1 | 2012-01-21 11:26:37 -0500 | [diff] [blame] | 23 | #define MF_VBEFLAGS 0xfe00 |
Kevin O'Connor | 821d6b4 | 2011-12-31 18:19:22 -0500 | [diff] [blame] | 24 | |
Kevin O'Connor | d4398ad | 2012-01-01 12:32:53 -0500 | [diff] [blame] | 25 | // Memory model types |
| 26 | #define MM_TEXT 0x00 |
| 27 | #define MM_CGA 0x01 |
| 28 | #define MM_HERCULES 0x02 |
| 29 | #define MM_PLANAR 0x03 |
| 30 | #define MM_PACKED 0x04 |
| 31 | #define MM_NON_CHAIN_4_256 0x05 |
| 32 | #define MM_DIRECT 0x06 |
| 33 | #define MM_YUV 0x07 |
| 34 | |
Kevin O'Connor | 10dff3d | 2012-01-09 19:19:44 -0500 | [diff] [blame] | 35 | struct vgamode_s { |
| 36 | u8 memmodel; |
| 37 | u16 width; |
| 38 | u16 height; |
| 39 | u8 depth; |
| 40 | u8 cwidth; |
| 41 | u8 cheight; |
| 42 | u16 sstart; |
| 43 | }; |
| 44 | |
Kevin O'Connor | f864b60 | 2014-03-24 12:49:44 -0400 | [diff] [blame] | 45 | // Graphics pixel operations. |
| 46 | struct gfx_op { |
| 47 | struct vgamode_s *vmode_g; |
| 48 | u32 linelength; |
Kevin O'Connor | 098c2fc | 2014-04-05 17:11:06 -0400 | [diff] [blame] | 49 | u32 displaystart; |
Kevin O'Connor | f864b60 | 2014-03-24 12:49:44 -0400 | [diff] [blame] | 50 | |
| 51 | u8 op; |
| 52 | u16 x, y; |
| 53 | |
| 54 | u8 pixels[8]; |
| 55 | u16 xlen, ylen; |
| 56 | u16 srcy; |
| 57 | }; |
| 58 | |
| 59 | #define GO_READ8 1 |
| 60 | #define GO_WRITE8 2 |
| 61 | #define GO_MEMSET 3 |
| 62 | #define GO_MEMMOVE 4 |
| 63 | |
Kevin O'Connor | 9978d49 | 2014-10-17 21:17:48 -0400 | [diff] [blame] | 64 | // Custom internal storage in BDA |
| 65 | #define VGA_CUSTOM_BDA 0xb9 |
| 66 | |
| 67 | struct vga_bda_s { |
Kevin O'Connor | f4b1dbc | 2014-10-21 15:15:44 -0400 | [diff] [blame] | 68 | u8 flags; |
Kevin O'Connor | 9978d49 | 2014-10-17 21:17:48 -0400 | [diff] [blame] | 69 | u16 vbe_mode; |
Kevin O'Connor | f7f2263 | 2014-10-17 21:37:23 -0400 | [diff] [blame] | 70 | u16 vgamode_offset; |
Kevin O'Connor | 9978d49 | 2014-10-17 21:17:48 -0400 | [diff] [blame] | 71 | } PACKED; |
| 72 | |
Kevin O'Connor | f4b1dbc | 2014-10-21 15:15:44 -0400 | [diff] [blame] | 73 | #define BF_PM_MASK 0x0f |
| 74 | |
Kevin O'Connor | 9978d49 | 2014-10-17 21:17:48 -0400 | [diff] [blame] | 75 | #define GET_BDA_EXT(var) \ |
| 76 | GET_FARVAR(SEG_BDA, ((struct vga_bda_s *)VGA_CUSTOM_BDA)->var) |
| 77 | #define SET_BDA_EXT(var, val) \ |
| 78 | SET_FARVAR(SEG_BDA, ((struct vga_bda_s *)VGA_CUSTOM_BDA)->var, (val)) |
| 79 | |
Kevin O'Connor | f864b60 | 2014-03-24 12:49:44 -0400 | [diff] [blame] | 80 | // Debug settings |
| 81 | #define DEBUG_VGA_POST 1 |
| 82 | #define DEBUG_VGA_10 3 |
| 83 | |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 84 | // vgafonts.c |
| 85 | extern u8 vgafont8[]; |
| 86 | extern u8 vgafont14[]; |
| 87 | extern u8 vgafont16[]; |
| 88 | extern u8 vgafont14alt[]; |
| 89 | extern u8 vgafont16alt[]; |
| 90 | |
Kevin O'Connor | dab0a74 | 2013-12-03 11:50:49 -0500 | [diff] [blame] | 91 | // vgainit.c |
Kevin O'Connor | 6397790 | 2014-10-23 16:24:36 -0400 | [diff] [blame] | 92 | extern struct video_save_pointer_s video_save_pointer_table; |
| 93 | extern struct video_param_s video_param_table[29]; |
Kevin O'Connor | dab0a74 | 2013-12-03 11:50:49 -0500 | [diff] [blame] | 94 | |
Kevin O'Connor | e1e000b | 2011-12-31 03:30:40 -0500 | [diff] [blame] | 95 | // vgabios.c |
Kevin O'Connor | 8cf8f8e | 2012-01-16 19:05:27 -0500 | [diff] [blame] | 96 | extern int VgaBDF; |
Kevin O'Connor | cfd7ef9 | 2012-02-02 22:52:17 -0500 | [diff] [blame] | 97 | extern int HaveRunInit; |
Kevin O'Connor | f376037 | 2011-12-23 22:41:08 -0500 | [diff] [blame] | 98 | #define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val)) |
Kevin O'Connor | 0926241 | 2009-05-25 11:44:11 -0400 | [diff] [blame] | 99 | struct carattr { |
Kevin O'Connor | 6ee837b | 2012-02-13 20:09:02 -0500 | [diff] [blame] | 100 | u8 car, attr, use_attr, pad; |
Kevin O'Connor | 0926241 | 2009-05-25 11:44:11 -0400 | [diff] [blame] | 101 | }; |
Kevin O'Connor | 918b156 | 2009-05-25 11:05:18 -0400 | [diff] [blame] | 102 | struct cursorpos { |
Kevin O'Connor | 6ee837b | 2012-02-13 20:09:02 -0500 | [diff] [blame] | 103 | u8 x, y, page, pad; |
Kevin O'Connor | 918b156 | 2009-05-25 11:05:18 -0400 | [diff] [blame] | 104 | }; |
Kevin O'Connor | 3876b53 | 2012-01-24 00:07:44 -0500 | [diff] [blame] | 105 | int vga_bpp(struct vgamode_s *vmode_g); |
Kevin O'Connor | 83047be | 2012-01-07 18:27:19 -0500 | [diff] [blame] | 106 | u16 calc_page_size(u8 memmodel, u16 width, u16 height); |
Kevin O'Connor | 20dc419 | 2014-02-05 20:52:25 -0500 | [diff] [blame] | 107 | int bda_save_restore(int cmd, u16 seg, void *data); |
Kevin O'Connor | 4a73f93 | 2012-01-21 11:08:35 -0500 | [diff] [blame] | 108 | struct vgamode_s *get_current_mode(void); |
Kevin O'Connor | e6bc4c1 | 2012-01-21 11:26:37 -0500 | [diff] [blame] | 109 | int vga_set_mode(int mode, int flags); |
Kevin O'Connor | 12900b1 | 2014-10-23 16:37:08 -0400 | [diff] [blame^] | 110 | extern struct video_func_static static_functionality; |
Kevin O'Connor | c0c7df6 | 2009-05-17 18:11:33 -0400 | [diff] [blame] | 111 | |
| 112 | // vgafb.c |
Kevin O'Connor | 7c79029 | 2014-02-11 15:34:58 -0500 | [diff] [blame] | 113 | void init_gfx_op(struct gfx_op *op, struct vgamode_s *vmode_g); |
| 114 | void handle_gfx_op(struct gfx_op *op); |
Kevin O'Connor | a02d418 | 2014-04-05 22:48:05 -0400 | [diff] [blame] | 115 | void *text_address(struct cursorpos cp); |
Kevin O'Connor | 7217ae7 | 2014-10-17 21:47:10 -0400 | [diff] [blame] | 116 | void vgafb_move_chars(struct cursorpos dest |
Kevin O'Connor | 7fd2af6 | 2014-03-20 21:16:28 -0400 | [diff] [blame] | 117 | , struct cursorpos src, struct cursorpos movesize); |
Kevin O'Connor | 7217ae7 | 2014-10-17 21:47:10 -0400 | [diff] [blame] | 118 | void vgafb_clear_chars(struct cursorpos dest |
Kevin O'Connor | 7fd2af6 | 2014-03-20 21:16:28 -0400 | [diff] [blame] | 119 | , struct carattr ca, struct cursorpos movesize); |
Kevin O'Connor | d3b3815 | 2009-05-26 00:05:37 -0400 | [diff] [blame] | 120 | void vgafb_write_char(struct cursorpos cp, struct carattr ca); |
| 121 | struct carattr vgafb_read_char(struct cursorpos cp); |
Kevin O'Connor | 227a2bb | 2009-05-31 22:00:20 -0400 | [diff] [blame] | 122 | void vgafb_write_pixel(u8 color, u16 x, u16 y); |
| 123 | u8 vgafb_read_pixel(u16 x, u16 y); |
Kevin O'Connor | c0c7df6 | 2009-05-17 18:11:33 -0400 | [diff] [blame] | 124 | |
Julian Pidancet | 87879e2 | 2011-12-19 05:08:00 +0000 | [diff] [blame] | 125 | // vbe.c |
Kevin O'Connor | 31f67ae | 2012-01-29 11:37:01 -0500 | [diff] [blame] | 126 | extern u32 VBE_total_memory; |
| 127 | extern u32 VBE_capabilities; |
| 128 | extern u32 VBE_framebuffer; |
| 129 | extern u16 VBE_win_granularity; |
Julian Pidancet | 87879e2 | 2011-12-19 05:08:00 +0000 | [diff] [blame] | 130 | #define VBE_OEM_STRING "SeaBIOS VBE(C) 2011" |
| 131 | #define VBE_VENDOR_STRING "SeaBIOS Developers" |
| 132 | #define VBE_PRODUCT_STRING "SeaBIOS VBE Adapter" |
| 133 | #define VBE_REVISION_STRING "Rev. 1" |
Kevin O'Connor | 4040195 | 2011-12-31 03:43:12 -0500 | [diff] [blame] | 134 | struct bregs; |
| 135 | void handle_104f(struct bregs *regs); |
| 136 | |
Kevin O'Connor | e1e000b | 2011-12-31 03:30:40 -0500 | [diff] [blame] | 137 | #endif // vgabios.h |