diff options
| author | H. Peter Anvin <hpa@linux.intel.com> | 2013-05-31 08:05:57 -0700 |
|---|---|---|
| committer | H. Peter Anvin <hpa@zytor.com> | 2013-05-31 08:08:36 -0700 |
| commit | c4fa33189f1d725fcd7c7457e45f37e970f5cdac (patch) | |
| tree | dd731a228b6023f4ff1e20a728d9e60634ed20a6 /core/include | |
| parent | be5a345d385d14bb740df7075c78dec5dcfbfc2a (diff) | |
| download | syslinux-c4fa33189f1d725fcd7c7457e45f37e970f5cdac.tar.gz | |
serial: Clean up and abstract handling of serial ports
The special handling of serial ports 0-3 meaning "look in a BIOS
table" is at least officially BIOS-specific, so create an inline
function and move it to bios.h.
While we are at it, make the function look slightly less like
converted assembly.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'core/include')
| -rw-r--r-- | core/include/bios.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/core/include/bios.h b/core/include/bios.h index 889443ab..6c3c8154 100644 --- a/core/include/bios.h +++ b/core/include/bios.h @@ -30,7 +30,7 @@ #define fdctab1 fdctab #define fdctab2 (fdctab + 2) -#define serial_base 0x0400 /* Base address for 4 serial ports */ +#define SERIAL_BASE 0x0400 /* Base address for 4 serial ports */ #define BIOS_fbm 0x0413 /* Free Base Memory (kilobytes) */ #define BIOS_page 0x0462 /* Current video page */ #define BIOS_timer 0x046C /* Timer ticks */ @@ -96,4 +96,19 @@ extern char *SerialTail; extern void bios_init(void); extern void bios_cleanup_hardware(void); +static inline uint16_t get_serial_port(uint16_t port) +{ + /* Magic array in BIOS memory, contains four entries */ + const uint16_t * const serial_ports = (const uint16_t *)SERIAL_BASE; + + /* + * If port > 3 then the port is simply the I/O base address + */ + if (port > 3) + return port; + + /* Get the I/O port from the BIOS */ + return serial_ports[port]; +} + #endif /* _BIOS_H */ |
