• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * -----------------------------------------------------------------------
3  *
4  *   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9  *   Boston MA 02111-1307, USA; either version 2 of the License, or
10  *   (at your option) any later version; incorporated herein by reference.
11  *
12  * -----------------------------------------------------------------------
13  *
14  *
15  * bios.h
16  *
17  * Header file for the BIOS data structures etc.
18  */
19 
20 #ifndef _BIOS_H
21 #define _BIOS_H
22 
23 #include <sys/io.h>
24 
25 /*
26  * Interrupt vectors
27  */
28 #define BIOS_timer_hook	(4 * 0x1C)
29 #define fdctab		(4 * 0x1E)
30 #define fdctab1		fdctab
31 #define fdctab2		(fdctab + 2)
32 
33 #define SERIAL_BASE	0x0400	/* Base address for 4 serial ports */
34 #define BIOS_fbm	0x0413	/* Free Base Memory (kilobytes) */
35 #define BIOS_page	0x0462	/* Current video page */
36 #define BIOS_timer	0x046C	/* Timer ticks */
37 #define BIOS_magic	0x0472	/* BIOS reset magic */
38 #define BIOS_vidrows	0x0484	/* Number of screen rows */
39 
bios_fbm(void)40 static inline uint16_t bios_fbm(void)
41 {
42 	return *(volatile uint16_t *)BIOS_fbm;
43 }
44 
set_bios_fbm(uint16_t mem)45 static inline void set_bios_fbm(uint16_t mem)
46 {
47 	*(volatile uint16_t *)BIOS_fbm = mem;
48 }
49 
50 #define serial_buf_size		4096
51 #define IO_DELAY_PORT		0x80 /* Invalid port (we hope!) */
52 
io_delay(void)53 static inline void io_delay(void)
54 {
55 	outb(0x0, IO_DELAY_PORT);
56 	outb(0x0, IO_DELAY_PORT);
57 }
58 
59 /*
60  * Sometimes we need to access screen coordinates as separate 8-bit
61  * entities and sometimes we need to use them as 16-bit entities. Using
62  * this structure allows the compiler to do it for us.
63  */
64 union screen {
65 	struct {
66 		uint8_t col;	/* Cursor column for message file */
67 		uint8_t row;	/* Cursor row for message file */
68 	} b;
69 	uint16_t dx;
70 };
71 extern union screen _cursor;
72 extern union screen _screensize;
73 
74 #define CursorDX	_cursor.dx
75 #define CursorCol	_cursor.b.col
76 #define CursorRow	_cursor.b.row
77 
78 #define ScreenSize	_screensize.dx
79 #define VidCols		_screensize.b.col
80 #define VidRows		_screensize.b.row
81 
82 /* font.c */
83 extern void use_font(void);
84 extern void bios_adjust_screen(void);
85 
86 /* serirq.c */
87 extern char *SerialHead;
88 extern char *SerialTail;
89 
90 extern void bios_init(void);
91 
get_serial_port(uint16_t port)92 static inline uint16_t get_serial_port(uint16_t port)
93 {
94     /* Magic array in BIOS memory, contains four entries */
95     const uint16_t * const serial_ports = (const uint16_t *)SERIAL_BASE;
96 
97     /*
98      * If port > 3 then the port is simply the I/O base address
99      */
100     if (port > 3)
101 	return port;
102 
103     /* Get the I/O port from the BIOS */
104     return serial_ports[port];
105 }
106 
107 #endif /* _BIOS_H */
108