blob: e2edec03b3862a48892c65c1a49ec2ca7a8e2f66 [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'Connor536129a2016-08-05 10:58:24 -04005#include "farptr.h" // GET_FARVAR
Kevin O'Connor1f2c3072009-05-06 23:35:59 -04006#include "types.h" // u8
Kevin O'Connoraad3b692012-01-14 23:15:40 -05007
Kevin O'Connor20dc4192014-02-05 20:52:25 -05008// 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'Connorca668642009-05-21 23:06:08 -040015
Kevin O'Connor821d6b42011-12-31 18:19:22 -050016// Mode flags
Kevin O'Connorb7b92932013-03-09 13:04:47 -050017#define MF_LEGACY 0x0001
Kevin O'Connor821d6b42011-12-31 18:19:22 -050018#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'Connore6bc4c12012-01-21 11:26:37 -050023#define MF_VBEFLAGS 0xfe00
Kevin O'Connor821d6b42011-12-31 18:19:22 -050024
Kevin O'Connord4398ad2012-01-01 12:32:53 -050025// 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'Connor10dff3d2012-01-09 19:19:44 -050035struct 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'Connor251e2632015-03-17 11:37:25 -040045// Custom internal storage in BDA (don't change here without also
46// updating vgaentry.S)
Kevin O'Connor9978d492014-10-17 21:17:48 -040047#define VGA_CUSTOM_BDA 0xb9
48
49struct vga_bda_s {
Kevin O'Connorf4b1dbc2014-10-21 15:15:44 -040050 u8 flags;
Kevin O'Connor9978d492014-10-17 21:17:48 -040051 u16 vbe_mode;
Kevin O'Connorf7f22632014-10-17 21:37:23 -040052 u16 vgamode_offset;
Kevin O'Connor9978d492014-10-17 21:17:48 -040053} PACKED;
54
Kevin O'Connor6fed3072014-10-30 12:09:19 -040055#define BF_PM_MASK 0x0f
56#define BF_EMULATE_TEXT 0x10
Kevin O'Connorb4eb6fc2014-10-17 22:15:42 -040057#define BF_SWCURSOR 0x20
Kevin O'Connor251e2632015-03-17 11:37:25 -040058#define BF_EXTRA_STACK 0x40
Kevin O'Connorf4b1dbc2014-10-21 15:15:44 -040059
Kevin O'Connor9978d492014-10-17 21:17:48 -040060#define GET_BDA_EXT(var) \
61 GET_FARVAR(SEG_BDA, ((struct vga_bda_s *)VGA_CUSTOM_BDA)->var)
62#define SET_BDA_EXT(var, val) \
63 SET_FARVAR(SEG_BDA, ((struct vga_bda_s *)VGA_CUSTOM_BDA)->var, (val))
Kevin O'Connor6fed3072014-10-30 12:09:19 -040064#define MASK_BDA_EXT(var, off, on) \
65 SET_BDA_EXT(var, (GET_BDA_EXT(var) & ~(off)) | (on))
66
67static inline int vga_emulate_text(void) {
68 return CONFIG_VGA_EMULATE_TEXT && GET_BDA_EXT(flags) & BF_EMULATE_TEXT;
69}
Kevin O'Connor9978d492014-10-17 21:17:48 -040070
Kevin O'Connor2f2ec112016-08-05 11:14:58 -040071// Write to global variables (during "post" phase only)
72#define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val))
73
Kevin O'Connorf864b602014-03-24 12:49:44 -040074// Debug settings
75#define DEBUG_VGA_POST 1
Paul Menzel970af162017-01-20 16:52:44 +010076#define DEBUG_VGA_10 9
Kevin O'Connorf864b602014-03-24 12:49:44 -040077
Kevin O'Connor536129a2016-08-05 10:58:24 -040078// vgabios.c
Kevin O'Connor3876b532012-01-24 00:07:44 -050079int vga_bpp(struct vgamode_s *vmode_g);
Kevin O'Connor83047be2012-01-07 18:27:19 -050080u16 calc_page_size(u8 memmodel, u16 width, u16 height);
Kevin O'Connorb4eb6fc2014-10-17 22:15:42 -040081u16 get_cursor_shape(void);
82struct cursorpos get_cursor_pos(u8 page);
Kevin O'Connor20dc4192014-02-05 20:52:25 -050083int bda_save_restore(int cmd, u16 seg, void *data);
Kevin O'Connor4a73f932012-01-21 11:08:35 -050084struct vgamode_s *get_current_mode(void);
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050085int vga_set_mode(int mode, int flags);
Kevin O'Connor12900b12014-10-23 16:37:08 -040086extern struct video_func_static static_functionality;
Kevin O'Connorc0c7df62009-05-17 18:11:33 -040087
Kevin O'Connore1e000b2011-12-31 03:30:40 -050088#endif // vgabios.h