blob: fd796f2e6b680acd9ab4318ae39916849f969ecc [file] [log] [blame]
Kevin O'Connore1e000b2011-12-31 03:30:40 -05001#ifndef __VGABIOS_H
2#define __VGABIOS_H
Kevin O'Connor1f2c3072009-05-06 23:35:59 -04003
Kevin O'Connor6fed3072014-10-30 12:09:19 -04004#include "config.h" // CONFIG_VGA_EMULATE_TEXT
Kevin O'Connor1f2c3072009-05-06 23:35:59 -04005#include "types.h" // u8
Kevin O'Connor9f985422009-09-09 11:34:39 -04006#include "farptr.h" // struct segoff_s
Kevin O'Connor63977902014-10-23 16:24:36 -04007#include "std/vga.h" // struct video_param_s
Kevin O'Connoraad3b692012-01-14 23:15:40 -05008
Kevin O'Connor20dc4192014-02-05 20:52:25 -05009// Save/Restore flags
10#define SR_HARDWARE 0x0001
11#define SR_BDA 0x0002
12#define SR_DAC 0x0004
13#define SR_REGISTERS 0x0008
14#define SR_SAVE 0x0100
15#define SR_RESTORE 0x0200
Kevin O'Connorca668642009-05-21 23:06:08 -040016
Kevin O'Connor821d6b42011-12-31 18:19:22 -050017// Mode flags
Kevin O'Connorb7b92932013-03-09 13:04:47 -050018#define MF_LEGACY 0x0001
Kevin O'Connor821d6b42011-12-31 18:19:22 -050019#define MF_GRAYSUM 0x0002
20#define MF_NOPALETTE 0x0008
21#define MF_CUSTOMCRTC 0x0800
22#define MF_LINEARFB 0x4000
23#define MF_NOCLEARMEM 0x8000
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050024#define MF_VBEFLAGS 0xfe00
Kevin O'Connor821d6b42011-12-31 18:19:22 -050025
Kevin O'Connord4398ad2012-01-01 12:32:53 -050026// Memory model types
27#define MM_TEXT 0x00
28#define MM_CGA 0x01
29#define MM_HERCULES 0x02
30#define MM_PLANAR 0x03
31#define MM_PACKED 0x04
32#define MM_NON_CHAIN_4_256 0x05
33#define MM_DIRECT 0x06
34#define MM_YUV 0x07
35
Kevin O'Connor10dff3d2012-01-09 19:19:44 -050036struct vgamode_s {
37 u8 memmodel;
38 u16 width;
39 u16 height;
40 u8 depth;
41 u8 cwidth;
42 u8 cheight;
43 u16 sstart;
44};
45
Kevin O'Connorf864b602014-03-24 12:49:44 -040046// Graphics pixel operations.
47struct gfx_op {
48 struct vgamode_s *vmode_g;
49 u32 linelength;
Kevin O'Connor098c2fc2014-04-05 17:11:06 -040050 u32 displaystart;
Kevin O'Connorf864b602014-03-24 12:49:44 -040051
52 u8 op;
53 u16 x, y;
54
55 u8 pixels[8];
56 u16 xlen, ylen;
57 u16 srcy;
58};
59
60#define GO_READ8 1
61#define GO_WRITE8 2
62#define GO_MEMSET 3
63#define GO_MEMMOVE 4
64
Kevin O'Connor9978d492014-10-17 21:17:48 -040065// Custom internal storage in BDA
66#define VGA_CUSTOM_BDA 0xb9
67
68struct vga_bda_s {
Kevin O'Connorf4b1dbc2014-10-21 15:15:44 -040069 u8 flags;
Kevin O'Connor9978d492014-10-17 21:17:48 -040070 u16 vbe_mode;
Kevin O'Connorf7f22632014-10-17 21:37:23 -040071 u16 vgamode_offset;
Kevin O'Connor9978d492014-10-17 21:17:48 -040072} PACKED;
73
Kevin O'Connor6fed3072014-10-30 12:09:19 -040074#define BF_PM_MASK 0x0f
75#define BF_EMULATE_TEXT 0x10
Kevin O'Connorb4eb6fc2014-10-17 22:15:42 -040076#define BF_SWCURSOR 0x20
Kevin O'Connorf4b1dbc2014-10-21 15:15:44 -040077
Kevin O'Connor9978d492014-10-17 21:17:48 -040078#define GET_BDA_EXT(var) \
79 GET_FARVAR(SEG_BDA, ((struct vga_bda_s *)VGA_CUSTOM_BDA)->var)
80#define SET_BDA_EXT(var, val) \
81 SET_FARVAR(SEG_BDA, ((struct vga_bda_s *)VGA_CUSTOM_BDA)->var, (val))
Kevin O'Connor6fed3072014-10-30 12:09:19 -040082#define MASK_BDA_EXT(var, off, on) \
83 SET_BDA_EXT(var, (GET_BDA_EXT(var) & ~(off)) | (on))
84
85static inline int vga_emulate_text(void) {
86 return CONFIG_VGA_EMULATE_TEXT && GET_BDA_EXT(flags) & BF_EMULATE_TEXT;
87}
Kevin O'Connor9978d492014-10-17 21:17:48 -040088
Kevin O'Connorf864b602014-03-24 12:49:44 -040089// Debug settings
90#define DEBUG_VGA_POST 1
91#define DEBUG_VGA_10 3
92
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040093// vgafonts.c
94extern u8 vgafont8[];
95extern u8 vgafont14[];
96extern u8 vgafont16[];
97extern u8 vgafont14alt[];
98extern u8 vgafont16alt[];
99
Kevin O'Connordab0a742013-12-03 11:50:49 -0500100// vgainit.c
Kevin O'Connor63977902014-10-23 16:24:36 -0400101extern struct video_save_pointer_s video_save_pointer_table;
102extern struct video_param_s video_param_table[29];
Kevin O'Connordab0a742013-12-03 11:50:49 -0500103
Kevin O'Connore1e000b2011-12-31 03:30:40 -0500104// vgabios.c
Kevin O'Connor8cf8f8e2012-01-16 19:05:27 -0500105extern int VgaBDF;
Kevin O'Connorcfd7ef92012-02-02 22:52:17 -0500106extern int HaveRunInit;
Kevin O'Connorf3760372011-12-23 22:41:08 -0500107#define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val))
Kevin O'Connor09262412009-05-25 11:44:11 -0400108struct carattr {
Kevin O'Connor6ee837b2012-02-13 20:09:02 -0500109 u8 car, attr, use_attr, pad;
Kevin O'Connor09262412009-05-25 11:44:11 -0400110};
Kevin O'Connor918b1562009-05-25 11:05:18 -0400111struct cursorpos {
Kevin O'Connor6ee837b2012-02-13 20:09:02 -0500112 u8 x, y, page, pad;
Kevin O'Connor918b1562009-05-25 11:05:18 -0400113};
Kevin O'Connor3876b532012-01-24 00:07:44 -0500114int vga_bpp(struct vgamode_s *vmode_g);
Kevin O'Connor83047be2012-01-07 18:27:19 -0500115u16 calc_page_size(u8 memmodel, u16 width, u16 height);
Kevin O'Connorb4eb6fc2014-10-17 22:15:42 -0400116u16 get_cursor_shape(void);
117struct cursorpos get_cursor_pos(u8 page);
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500118int bda_save_restore(int cmd, u16 seg, void *data);
Kevin O'Connor4a73f932012-01-21 11:08:35 -0500119struct vgamode_s *get_current_mode(void);
Kevin O'Connore6bc4c12012-01-21 11:26:37 -0500120int vga_set_mode(int mode, int flags);
Kevin O'Connor12900b12014-10-23 16:37:08 -0400121extern struct video_func_static static_functionality;
Kevin O'Connorc0c7df62009-05-17 18:11:33 -0400122
123// vgafb.c
Kevin O'Connor7c790292014-02-11 15:34:58 -0500124void init_gfx_op(struct gfx_op *op, struct vgamode_s *vmode_g);
125void handle_gfx_op(struct gfx_op *op);
Kevin O'Connora02d4182014-04-05 22:48:05 -0400126void *text_address(struct cursorpos cp);
Kevin O'Connor7217ae72014-10-17 21:47:10 -0400127void vgafb_move_chars(struct cursorpos dest
Kevin O'Connor7fd2af62014-03-20 21:16:28 -0400128 , struct cursorpos src, struct cursorpos movesize);
Kevin O'Connor7217ae72014-10-17 21:47:10 -0400129void vgafb_clear_chars(struct cursorpos dest
Kevin O'Connor7fd2af62014-03-20 21:16:28 -0400130 , struct carattr ca, struct cursorpos movesize);
Kevin O'Connord3b38152009-05-26 00:05:37 -0400131void vgafb_write_char(struct cursorpos cp, struct carattr ca);
132struct carattr vgafb_read_char(struct cursorpos cp);
Kevin O'Connor227a2bb2009-05-31 22:00:20 -0400133void vgafb_write_pixel(u8 color, u16 x, u16 y);
134u8 vgafb_read_pixel(u16 x, u16 y);
Kevin O'Connorb4eb6fc2014-10-17 22:15:42 -0400135void vgafb_set_swcursor(int enable);
Kevin O'Connorc0c7df62009-05-17 18:11:33 -0400136
Julian Pidancet87879e22011-12-19 05:08:00 +0000137// vbe.c
Kevin O'Connor31f67ae2012-01-29 11:37:01 -0500138extern u32 VBE_total_memory;
139extern u32 VBE_capabilities;
140extern u32 VBE_framebuffer;
141extern u16 VBE_win_granularity;
Julian Pidancet87879e22011-12-19 05:08:00 +0000142#define VBE_OEM_STRING "SeaBIOS VBE(C) 2011"
143#define VBE_VENDOR_STRING "SeaBIOS Developers"
144#define VBE_PRODUCT_STRING "SeaBIOS VBE Adapter"
145#define VBE_REVISION_STRING "Rev. 1"
Kevin O'Connor40401952011-12-31 03:43:12 -0500146struct bregs;
147void handle_104f(struct bregs *regs);
148
Kevin O'Connore1e000b2011-12-31 03:30:40 -0500149#endif // vgabios.h