summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlaredo <nlaredo@ca484b36-2546-0410-af21-7957cbf944c2>2010-04-22 00:03:40 +0000
committernlaredo <nlaredo@ca484b36-2546-0410-af21-7957cbf944c2>2010-04-22 00:03:40 +0000
commit23d474943dcd55d0550a3d20b3d30e9040a4f15b (patch)
treea85446adb0e07ccd5211619a6f215bcfc3c5ab29
parent8eb5346034c7dbd15694d59d7e1db2eec8a689f9 (diff)
downloadqemu-sgabios-23d474943dcd55d0550a3d20b3d30e9040a4f15b.tar.gz
new review:
owner: nil@google.com summary: build cleanup including proper checksum and image padding git-svn-id: http://sgabios.googlecode.com/svn/trunk@8 ca484b36-2546-0410-af21-7957cbf944c2
-rw-r--r--Makefile69
-rw-r--r--csum8.c64
-rw-r--r--rom16.ld133
-rw-r--r--sgabios.S2788
-rw-r--r--sgabios.h76
5 files changed, 1697 insertions, 1433 deletions
diff --git a/Makefile b/Makefile
index f44290e..970b0ff 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2007 Google Inc.
+# Copyright 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,22 +14,65 @@
#
# $Id$
-CFLAGS = -Wall -O2 -s
+BUILD_DATE = \"$(shell date -u)\"
+BUILD_SHORT_DATE = \"$(shell date -u +%D)\"
+BUILD_HOST = \"$(shell hostname)\"
+BUILD_USER = \"$(shell whoami)\"
-.SUFFIXES: .bin
+CFLAGS := -Wall -Os -m32 -nostdlib
-all: sgabios.bin
+ASFLAGS := $(CFLAGS)
+ASFLAGS += -DBUILD_DATE="$(BUILD_DATE)"
+ASFLAGS += -DBUILD_SHORT_DATE="$(BUILD_SHORT_DATE)"
+ASFLAGS += -DBUILD_HOST="$(BUILD_HOST)"
+ASFLAGS += -DBUILD_USER="$(BUILD_USER)"
-sgabios.bin: sgabios.S version.h
+LDSCRIPT := rom16.ld
+LDFLAGS := -T $(LDSCRIPT) -nostdlib
+OBJCOPY := objcopy
-version.h: Makefile sgabios.S
- @echo '#define BIOS_BUILD_DATE "'`date -u +%D`'"' >version.h
- @echo '#define BIOS_FULL_DATE "'`date -u`'"' >>version.h
- @echo '#define BIOS_BUILD_HOST "'`echo $$LOGNAME@$$HOSTNAME`'"' >>version.h
+ASRCS = sgabios.S
-.S.bin:
- $(CC) -c $(CFLAGS) $*.S -o $*.o
- $(LD) -Ttext 0x0 -s --oformat binary $*.o -o $*.bin
+CSRCS =
+SRCS = $(CSRCS) $(ASRCS)
+
+OBJS = ${CSRCS:.c=.o} ${ASRCS:.S=.o}
+INCS = ${CSRCS:.c=.h} ${ASRCS:.S=.h}
+
+PROGS = sgabios.bin csum8
+
+.SUFFIXES: .bin .elf
+.PHONY: buildinfo
+
+all: $(PROGS)
+
+sgabios.bin: sgabios.elf
+ $(OBJCOPY) -O binary $< $@
+ ./csum8 $@
+
+sgabios.elf: .depend $(OBJS) $(LDSCRIPT) csum8
+ $(LD) $(LDFLAGS) $(OBJS) -o $@
+
+csum8: csum8.c
+ $(CC) -Wall -O2 -o $@ $<
+
+sgabios.o: buildinfo
+
+
+buildinfo:
+ touch sgabios.S
clean:
- $(RM) *.s *.o *.bin *.srec *.com version.h
+ $(RM) $(PROGS) $(OBJS) *.elf *.srec *.com version.h
+
+.depend:: $(INCS) $(SRCS) Makefile
+ $(RM) .depend
+ $(CPP) -M $(CFLAGS) $(SRCS) >.tmpdepend && mv .tmpdepend .depend
+
+ifeq (.depend, $(wildcard .depend))
+include .depend
+else
+# if no .depend file existed, add a make clean to the end of building .depend
+.depend::
+ $(MAKE) clean
+endif
diff --git a/csum8.c b/csum8.c
new file mode 100644
index 0000000..6962913
--- /dev/null
+++ b/csum8.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * compute rom checksum byte
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+
+#define MAX_SIZE 65536
+unsigned char buf[MAX_SIZE];
+
+int main(int argc, char **argv)
+{
+ ssize_t fsize;
+ int i, sum, fd;
+ unsigned char csum;
+
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s filename\n", argv[0]);
+ exit(1);
+ }
+ if ((fd = open(argv[1], O_RDWR)) < 0) {
+ perror(argv[1]);
+ exit(1);
+ }
+ if ((fsize = read(fd, buf, MAX_SIZE)) < 0) {
+ perror(argv[1]);
+ exit(1);
+ }
+ if (fsize >= MAX_SIZE && read(fd, &buf[MAX_SIZE - 1], 1) > 0) {
+ fprintf(stderr, "FAIL: %s is larger than %d bytes\n", argv[1], MAX_SIZE);
+ exit(1);
+ }
+ i = fsize - 2048 * (fsize / 2048);
+ if (i != 2047) {
+ fprintf(stderr, "FAIL: %s is %zd bytes, need 2K pad-1\n", argv[1], fsize);
+ exit(1);
+ }
+ for (i = sum = 0; i < fsize; i++) {
+ sum += buf[i];
+ }
+ sum &= 0xff;
+ csum = -sum & 0xff;
+ write(fd, &csum, 1);
+ close(fd);
+ fprintf(stderr, "%s: sum = 0x%02x, wrote byte 0x%02x\n", argv[1], sum, csum);
+ return 0;
+}
diff --git a/rom16.ld b/rom16.ld
new file mode 100644
index 0000000..4eaa122
--- /dev/null
+++ b/rom16.ld
@@ -0,0 +1,133 @@
+/*
+ * Linker script for ROM16 binaries
+ */
+
+/* Script for -z combreloc: combine and sort reloc sections */
+OUTPUT_FORMAT("elf32-i386", "elf32-i386",
+ "elf32-i386")
+OUTPUT_ARCH(i386)
+EXTERN(_start)
+ENTRY(_start)
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = 0x0;
+ PROVIDE (__executable_start = .);
+
+ .init :
+ {
+ KEEP (*(.init))
+ } =0x90909090
+ .text :
+ {
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ } =0x90909090
+ .fini :
+ {
+ KEEP (*(.fini))
+ } =0x90909090
+ PROVIDE (__etext = .);
+ PROVIDE (_etext = .);
+ PROVIDE (etext = .);
+ .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
+ .rodata1 : { *(.rodata1) }
+
+ /* Ensure the __preinit_array_start label is properly aligned. We
+ could instead move the label definition inside the section, but
+ the linker would then create the section even if it turns out to
+ be empty, which isn't pretty. */
+ . = ALIGN(4);
+ PROVIDE (__preinit_array_start = .);
+ .preinit_array : { *(.preinit_array) }
+ PROVIDE (__preinit_array_end = .);
+ PROVIDE (__init_array_start = .);
+ .init_array : { *(.init_array) }
+ PROVIDE (__init_array_end = .);
+ PROVIDE (__fini_array_start = .);
+ .fini_array : { *(.fini_array) }
+ PROVIDE (__fini_array_end = .);
+ PROVIDE (__ctors_start = .);
+ .ctors :
+ {
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ }
+ PROVIDE (__ctors_end = .);
+ PROVIDE (__dtors_start = .);
+ .dtors :
+ {
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ }
+ PROVIDE (__dtors_end = .);
+
+ /* Adjust the address for the data segment. Avoid mixing code and
+ data within same 128-byte chunk. */
+ . = ALIGN(128);
+
+ .data :
+ {
+ *(.data .data.* .gnu.linkonce.d.*)
+ SORT(CONSTRUCTORS)
+ }
+ .data1 : { *(.data1) }
+ _edata = .;
+ PROVIDE (edata = .);
+ __bss_start = .;
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss .bss.* .gnu.linkonce.b.*)
+ *(COMMON)
+ /* Align here to ensure that the .bss section occupies space up to
+ _end. Align after .bss to ensure correct alignment even if the
+ .bss section disappears because there are no input sections. */
+ . = ALIGN(32 / 8);
+ }
+ .csum :
+ {
+ . = ALIGN(2048) - 5;
+ LONG(0xff4c494e);
+ /* BYTE(_rom_size_byte); */
+ } =0xffffffff
+ _end = .;
+ PROVIDE (end = .);
+ PROVIDE(_rom_size_byte = (511 + end) / 512);
+
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/sgabios.S b/sgabios.S
index 6d63f58..275d063 100644
--- a/sgabios.S
+++ b/sgabios.S
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,83 +14,28 @@
* limitations under the License.
*/
-#include "version.h"
-
-/* don't allocate ebda if new value at 0x40e will be less than this */
-#define EBDA_MIN_SEG 0x9800
-#define SGABIOS_EBDA_KB 1
-/* note: no testing has yet been done logging other than 256 bytes */
-#define SGABIOS_EBDA_BYTES (SGABIOS_EBDA_KB*1024)
-#define SGABIOS_EBDA_DELTA (SGABIOS_EBDA_BYTES/16)
-#define SGABIOS_EBDA_LOG_START 256
-#define SGABIOS_EBDA_LOG_SIZE 256
-#define SGABIOS_EBDA_POS_START (SGABIOS_EBDA_LOG_START+SGABIOS_EBDA_LOG_SIZE)
-#define SGABIOS_EBDA_POS_LAST (SGABIOS_EBDA_POS_START+(SGABIOS_EBDA_LOG_SIZE*2)-2)
-
-/* serial costants that may require modification */
-#define COM_BASE_ADDR 0x3f8
-#define PORT_SPEED 115200
-#define LCR_VALUE 0x13 /* 8n1 */
-
-/* serial constants below shouldn't require modification */
-#define IER_OFFSET 0x01
-#define FCR_OFFSET 0x02
-#define LCR_OFFSET 0x03
-#define MCR_OFFSET 0x04
-#define LSR_OFFSET 0x05
-#define MSR_OFFSET 0x06
-#define SCR_OFFSET 0x07
-#define LCR_DLAB 0x80
-#define MCR_DTRRTS 0x03
-#define FCR_FIFO_ENABLE 0x01
-#define PORT_DIVISOR 115200
-#define TRANSMIT_READY_BIT 0x20
-#define BIOS_BUILD_VERSION "$Id$"
-
-#define KBD_HEAD 0x1a
-#define KBD_TAIL 0x1c
-#define KBD_BUF_START 0x1e
-#define KBD_BUF_END 0x3e
-
-#define VGA_IO_BASE 0x3d4
-#define BDA_SEG 0x40
-#define BDA_EBDA 0x0e
-#define BDA_MEM_SIZE 0x13
-#define BDA_MODE_NUM 0x49
-#define BDA_COLS 0x4a
-#define BDA_PAGE_SIZE 0x4c
-/* BDA word 40:0c traditionally holds the LPT3 io port address... */
-/* Reuse it for tracking where the serial console cursor was left */
-/* Don't send ansi cursor pos update without text ready to output */
-/* Some operations don't update cursor position, but next int 10h */
-/* call is often one that might update to where cursor already is */
-#define BDA_SERIAL_POS 0x0c
-#define BDA_CURSOR_BUF 0x50
-#define BDA_CURSOR_COL 0x50
-#define BDA_CURSOR_ROW 0x51
-#define BDA_CURSOR_SCAN 0x60
-#define BDA_ACTIVE_PAGE 0x62
-#define BDA_6845_ADDR 0x63
-#define BDA_MODE_SEL 0x65
-#define BDA_COLOR_VAL 0x66
-#define BDA_ROM_OFF 0x67
-#define BDA_ROM_SEG 0x69
-#define BDA_ROWS 0x84
+#include "sgabios.h"
+#define BUILD_CL "$Id$"
.code16
-.org 0x0
.text
-.global _start
+ .section ".init","ax"
+ .globl _start
+ .type _start,@object
_start:
- /* option rom header */
- .byte 0x55
- .byte 0xaa
- .byte (511 + _end_sgabios - _start)/512
- /* legacy entry at offset 3 */
- jmp pnp_sga_init
- /* pnp entry here to avoid changing PnP table as code moves */
+ /* option rom header */
+ .byte 0x55
+ .byte 0xaa
+ .byte _rom_size_byte
+ .size _start, .-_start
+
+ .globl legacy_entry
+ .type legacy_entry,@function
+legacy_entry:
+ jmp sga_init
+ /* pnp entry here to avoid changing PnP table as code moves */
pnp_init:
- jmp pnp_sga_init
+ jmp pnp_sga_init
/*
* do_old_int10h
@@ -99,13 +44,13 @@ pnp_init:
*
*/
do_old_int10h:
- .byte 0xea /* jmp absolute segment:offset */
-old_int10h: /* store what was at offset 0x40 */
- .word 0xf065 /* placeholder for chained ISR offset */
- /* if the chained segment is detected as 0xc000, use 80 cols only */
- /* since it's assumed that a vga card is attached and 80 cols max */
+ .byte 0xea /* jmp absolute segment:offset */
+old_int10h: /* store what was at offset 0x40 */
+ .word 0xf065 /* placeholder for chained ISR offset */
+ /* if the chained segment is detected as 0xc000, use 80 cols only */
+ /* since it's assumed that a vga card is attached and 80 cols max */
old_int10h_seg:
- .word 0xf000 /* placeholder for chained ISR segment */
+ .word 0xf000 /* placeholder for chained ISR segment */
/*
* do_old_int16h
*
@@ -113,62 +58,64 @@ old_int10h_seg:
*
*/
do_old_int16h:
- .byte 0xea /* jmp absolute segment:offset */
-old_int16h: /* store what was at offset 0x58 */
- .word 0xe82e /* placeholder for chained ISR offset */
- .word 0xf000 /* placeholder for chained ISR segment */
+ .byte 0xea /* jmp absolute segment:offset */
+old_int16h: /* store what was at offset 0x58 */
+ .word 0xe82e /* placeholder for chained ISR offset */
+ .word 0xf000 /* placeholder for chained ISR segment */
.org 0x18
- .word 0 /* offset to PCI data, 0 = none */
- .word pnp_table /* offset to PnP expansion header */
+ .word 0 /* offset to PCI data, 0 = none */
+ .word pnp_table /* offset to PnP expansion header */
.org 0x20
pnp_table:
- /* FIXME: **** PnP header currently disabled by PoO **** */
- /* legacy entry only called once, PnP entry called multiple times */
- /* The code isn't yet written to deal with multiple inits properly */
- .ascii "$PoO" /* PnP expansion header signature */
- .byte 1 /* structure revision */
- .byte 2 /* length in 16-byte increments */
- .word 0 /* offset of next header, 0 if none */
- .byte 0 /* reserved */
- .byte 0x52 /* checksum - update manually! FIXME */
- .long 0 /* device identifier */
- .word mfg_string /* pointer to manufacturer string */
- .word prod_string /* pointer to product name string */
- .byte 3, 0x80, 0x80 /* device type code = other display */
- .byte 0xe3 /* device indicators, input/display dev */
- .word 0 /* boot connection vector, 0 if none */
- .word 0 /* disconnect vector, 0 if none */
- .word pnp_init /* bootstrap entry vector */
- .word 0 /* reserved */
- .word 0 /* static resource information vector */
-
- /* WARNING: changing mfg_string / prod_string locations will */
- /* affect pnp table above -- recalculate checksum manually! */
+ /* FIXME: **** PnP header currently disabled by PoO **** */
+ /* legacy entry only called once, PnP entry called multiple times */
+ /* The code isn't yet written to deal with multiple inits properly */
+ .ascii "$PoO" /* PnP expansion header signature */
+ .byte 1 /* structure revision */
+ .byte 2 /* length in 16-byte increments */
+ .word 0 /* offset of next header, 0 if none */
+ .byte 0 /* reserved */
+ .byte 0x52 /* checksum - update manually! FIXME */
+ .long 0 /* device identifier */
+ .word mfg_string /* pointer to manufacturer string */
+ .word prod_string /* pointer to product name string */
+ .byte 3, 0x80, 0x80 /* device type code = other display */
+ .byte 0xe3 /* device indicators, kbd/display dev */
+ .word 0 /* boot connection vector, 0 if none */
+ .word 0 /* disconnect vector, 0 if none */
+ .word pnp_init /* bootstrap entry vector */
+ .word 0 /* reserved */
+ .word 0 /* static resource information vector */
+
+ /* WARNING: changing mfg_string / prod_string locations will */
+ /* affect pnp table above -- recalculate checksum manually! */
mfg_string:
- .asciz "Google, Inc."
+ .asciz "Google, Inc."
prod_string:
- .ascii "Serial Graphics Adapter "
+ .ascii "Serial Graphics Adapter "
build_date:
- .asciz BIOS_BUILD_DATE
+ .asciz BUILD_SHORT_DATE
long_version:
- .ascii "SGABIOS Version "
- .ascii BIOS_BUILD_VERSION
- .ascii " ("
- .ascii BIOS_BUILD_HOST
- .ascii ") "
- .asciz BIOS_FULL_DATE
+ .ascii "SGABIOS "
+ .ascii BUILD_CL
+ .ascii " ("
+ .ascii BUILD_USER
+ .ascii "@"
+ .ascii BUILD_HOST
+ .ascii ") "
+ .asciz BUILD_DATE
term_cols:
- .byte 80 /* overwritten at rom init with detected value */
+ .byte 80 /* overwritten at rom init with detected value */
term_rows:
- .byte 24 /* overwritten at rom init with detected value */
-term_init_string: /* terminal reply: \033[n;mR n=row, m=col */
- .asciz "\033[1;256r\033[256;256H\033[6n"
- /* reset the scroll, move to col 256, row 256, ask current position */
- /* bios cursor positions >255 rows or cols can't be used anyway */
+ .byte 24 /* overwritten at rom init with detected value */
+term_init_string: /* terminal reply: \033[n;mR n=row, m=col */
+ .asciz "\033[1;256r\033[256;256H\033[6n"
+ /* reset the scroll, move to col 256, row 256, ask current position */
+ /* bios cursor positions >255 rows or cols can't be used anyway */
term_info:
- .asciz "Term: "
+ .asciz "Term: "
ebda_info:
- .asciz "EBDA: "
+ .asciz "EBDA: "
/*
* do_old_irq3 - exception 0x0b, int 0x0a
@@ -177,10 +124,10 @@ ebda_info:
*
*/
do_old_irq3:
- .byte 0xea /* jmp absolute segment:offset */
-old_irq3: /* store what was at offset 0x28 */
- .word 0xeef3 /* placeholder for chained ISR offset */
- .word 0xf000 /* placeholder for chained ISR segment */
+ .byte 0xea /* jmp absolute segment:offset */
+old_irq3: /* store what was at offset 0x28 */
+ .word 0xeef3 /* placeholder for chained ISR offset */
+ .word 0xf000 /* placeholder for chained ISR segment */
/*
* do_old_irq4 - exception 0x0c, int 0x0b
@@ -189,10 +136,10 @@ old_irq3: /* store what was at offset 0x28 */
*
*/
do_old_irq4:
- .byte 0xea /* jmp absolute segment:offset */
-old_irq4: /* store what was at offset 0x2c */
- .word 0xeef3 /* placeholder for chained ISR offset */
- .word 0xf000 /* placeholder for chained ISR segment */
+ .byte 0xea /* jmp absolute segment:offset */
+old_irq4: /* store what was at offset 0x2c */
+ .word 0xeef3 /* placeholder for chained ISR offset */
+ .word 0xf000 /* placeholder for chained ISR segment */
/*
* do_old_int14h
@@ -201,32 +148,32 @@ old_irq4: /* store what was at offset 0x2c */
*
*/
do_old_int14h:
- .byte 0xea /* jmp absolute segment:offset */
-old_int14h: /* store what was at offset 0x50 */
- .word 0xe739 /* placeholder for chained ISR offset */
- .word 0xf000 /* placeholder for chained ISR segment */
+ .byte 0xea /* jmp absolute segment:offset */
+old_int14h: /* store what was at offset 0x50 */
+ .word 0xe739 /* placeholder for chained ISR offset */
+ .word 0xf000 /* placeholder for chained ISR segment */
-.align 16, 0xff /* aligning this table only makes hexdump prettier */
+.align 16, 0xff /* aligning this table only makes hexdump prettier */
/* ascii -> scancode, bit 7=shifted, char < 32 = +ctrl */
/* except chars 8, 9, 13, 27 (bs, tab, enter, esc) */
/* most int16h consumers will probably never use */
ascii2scan:
-/*00*/ .byte 0x00, 0x1e, 0x30, 0x2e, 0x20, 0x12, 0x21, 0x22
-/*08*/ .byte 0x0e, 0x17, 0x24, 0x25, 0x26, 0x1c, 0x31, 0x18
-/*10*/ .byte 0x19, 0x0f, 0x13, 0x1f, 0x14, 0x16, 0x2f, 0x11
-/*18*/ .byte 0x2d, 0x15, 0x2c, 0x01, 0x2b, 0x1b, 0x87, 0x8c
-/*20*/ .byte 0x39, 0x82, 0xa8, 0x84, 0x85, 0x86, 0x88, 0x28
-/*28*/ .byte 0x8a, 0x8b, 0x89, 0x8d, 0x33, 0x0c, 0x34, 0x35
-/*30*/ .byte 0x0b, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
-/*38*/ .byte 0x09, 0x0a, 0xa7, 0x27, 0xb3, 0x0d, 0x34, 0xb5
-/*40*/ .byte 0x83, 0x9e, 0xb0, 0xae, 0xa0, 0x92, 0xa1, 0xa2
-/*48*/ .byte 0xa3, 0x97, 0xa4, 0xa5, 0xa6, 0xb2, 0xb1, 0x98
-/*50*/ .byte 0x99, 0x90, 0x93, 0x9f, 0x94, 0x96, 0xaf, 0x91
-/*58*/ .byte 0xad, 0x95, 0xac, 0x1a, 0x2b, 0x1b, 0x87, 0x8c
-/*60*/ .byte 0x29, 0x1e, 0x30, 0x2e, 0x20, 0x12, 0x21, 0x22
-/*68*/ .byte 0x23, 0x17, 0x24, 0x25, 0x26, 0x32, 0x31, 0x18
-/*70*/ .byte 0x19, 0x10, 0x13, 0x1f, 0x14, 0x16, 0x2f, 0x11
-/*78*/ .byte 0x2d, 0x15, 0x2c, 0x9a, 0xab, 0x9b, 0xa9, 0x0e
+/*00*/ .byte 0x00, 0x1e, 0x30, 0x2e, 0x20, 0x12, 0x21, 0x22
+/*08*/ .byte 0x0e, 0x17, 0x24, 0x25, 0x26, 0x1c, 0x31, 0x18
+/*10*/ .byte 0x19, 0x0f, 0x13, 0x1f, 0x14, 0x16, 0x2f, 0x11
+/*18*/ .byte 0x2d, 0x15, 0x2c, 0x01, 0x2b, 0x1b, 0x87, 0x8c
+/*20*/ .byte 0x39, 0x82, 0xa8, 0x84, 0x85, 0x86, 0x88, 0x28
+/*28*/ .byte 0x8a, 0x8b, 0x89, 0x8d, 0x33, 0x0c, 0x34, 0x35
+/*30*/ .byte 0x0b, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
+/*38*/ .byte 0x09, 0x0a, 0xa7, 0x27, 0xb3, 0x0d, 0x34, 0xb5
+/*40*/ .byte 0x83, 0x9e, 0xb0, 0xae, 0xa0, 0x92, 0xa1, 0xa2
+/*48*/ .byte 0xa3, 0x97, 0xa4, 0xa5, 0xa6, 0xb2, 0xb1, 0x98
+/*50*/ .byte 0x99, 0x90, 0x93, 0x9f, 0x94, 0x96, 0xaf, 0x91
+/*58*/ .byte 0xad, 0x95, 0xac, 0x1a, 0x2b, 0x1b, 0x87, 0x8c
+/*60*/ .byte 0x29, 0x1e, 0x30, 0x2e, 0x20, 0x12, 0x21, 0x22
+/*68*/ .byte 0x23, 0x17, 0x24, 0x25, 0x26, 0x32, 0x31, 0x18
+/*70*/ .byte 0x19, 0x10, 0x13, 0x1f, 0x14, 0x16, 0x2f, 0x11
+/*78*/ .byte 0x2d, 0x15, 0x2c, 0x9a, 0xab, 0x9b, 0xa9, 0x0e
/* TABLES FOR NON-ASCII VGA CHARACTERS (CP437) TO ASCII */
/* Unicode at: http://en.wikipedia.org/wiki/Code_page_437 */
@@ -235,23 +182,23 @@ ctrl2ascii:
/* translate vga (CP437) first 32 characters to ascii */
/* for char 0, update the cursor position, but output nothing */
/* lilo uses this "trick" for a background attribute update */
- .ascii "\0@@v***........*><|!PS-|^v><L-^v"
+ .ascii "\0@@v***........*><|!PS-|^v><L-^v"
high2ascii:
/* translate vga (CP437) chars 0x80 to 0xff to ascii */
/* these characters are mostly to visually approximate */
/* line art characters will probably need tweaking */
-/*80*/ .ascii "CueaaaaceeeiiiAAEaAooouuyOUcLYPf"
-/*a0*/ .ascii "aiounNao?--24!<>###||||++||+++++"
-/*c0*/ .ascii "+--|-+||++--|-+----++++++++#-||-"
-/*e0*/ .ascii "abgpesut00osiye^=+><||-=...vn2* "
+/*80*/ .ascii "CueaaaaceeeiiiAAEaAooouuyOUcLYPf"
+/*a0*/ .ascii "aiounNao?--24!<>###||||++||+++++"
+/*c0*/ .ascii "+--|-+||++--|-+----++++++++#-||-"
+/*e0*/ .ascii "abgpesut00osiye^=+><||-=...vn2* "
colortable:
/* vga text color is IRGB, ansi color is BGR */
/* this table is effectively a nibble bit-reverse */
- .byte 0, 4, 2, 6, 1, 5, 3, 7
+ .byte 0, 4, 2, 6, 1, 5, 3, 7
serial_port_base_address:
- .word COM_BASE_ADDR
+ .word COM_BASE_ADDR
/* in-memory console log
*
@@ -262,17 +209,17 @@ serial_port_base_address:
* bit logged character count, followed by an 8-bit flag.
*/
-#define MEMCONSOLE_BUFFER_SIZE 32768
-#define MEMCONSOLE_SIGNATURE 0xdeadbabe
-#define MEMCONSOLE_ENDINDEX_OFF 0x0b
-#define SGABIOS_EBDA_SIGNATURE 0x00414753
+#define MEMCONSOLE_BUFFER_SIZE 32768
+#define MEMCONSOLE_SIGNATURE 0xdeadbabe
+#define MEMCONSOLE_ENDINDEX_OFF 0x0b
+#define SGABIOS_EBDA_SIGNATURE 0x00414753
-memconsole_buffer_start: /* pulled from ebda struct */
- .long 0x00000000 /* 0 = not found/no logging */
-memconsole_ebda_deadbabe_offset: /* bytes from start of ebda */
- .word 0x0000 /* 40:0e contains ebda seg */
-sgabios_ebda_logbuf_offset: /* bytes from start of ebda */
- .word 0x0000 /* 40:0e contains ebda seg */
+memconsole_buffer_start: /* pulled from ebda struct */
+ .long 0x00000000 /* 0 = not found/no logging */
+memconsole_ebda_deadbabe_offset: /* bytes from start of ebda */
+ .word 0x0000 /* 40:0e contains ebda seg */
+sgabios_ebda_logbuf_offset: /* bytes from start of ebda */
+ .word 0x0000 /* 40:0e contains ebda seg */
/*
* setup_memconsole
@@ -287,32 +234,32 @@ sgabios_ebda_logbuf_offset: /* bytes from start of ebda */
*/
setup_memconsole:
- pushaw
- pushw %ds
- pushw %es
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- pushw BDA_EBDA /* push word at 0x0e */
- popw %es /* es = EBDA_SEG */
- /* search for memconsole signature in ebda */
- movl $MEMCONSOLE_SIGNATURE, %eax
- xorw %di, %di /* start at zero */
- movzbw %es:(%di), %cx /* cx = size of EBDA in KB */
- shlw $8, %cx /* cx = (cx * 1024) / 4 */
- cld
- repnz
- scasl /* search until sig found */
- subw $4, %di /* scasl always increments di, undo */
- cmpl %eax, %es:(%di) /* is signature here? */
- jnz setup_memconsole_end /* bail if so */
- movw %di, %cs:memconsole_ebda_deadbabe_offset /* save offset */
- movl %es:5(%di), %eax /* get 32-bit buffer base address */
- movl %eax, %cs:memconsole_buffer_start
+ pushaw
+ pushw %ds
+ pushw %es
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ pushw BDA_EBDA /* push word at 0x0e */
+ popw %es /* es = EBDA_SEG */
+ /* search for memconsole signature in ebda */
+ movl $MEMCONSOLE_SIGNATURE, %eax
+ xorw %di, %di /* start at zero */
+ movzbw %es:(%di), %cx /* cx = size of EBDA in KB */
+ shlw $8, %cx /* cx = (cx * 1024) / 4 */
+ cld
+ repnz
+ scasl /* search until sig found */
+ subw $4, %di /* scasl always increments di, undo */
+ cmpl %eax, %es:(%di) /* is signature here? */
+ jnz setup_memconsole_end /* bail if so */
+ movw %di, %cs:memconsole_ebda_deadbabe_offset /* save offset */
+ movl %es:5(%di), %eax /* get 32-bit buffer base address */
+ movl %eax, %cs:memconsole_buffer_start
setup_memconsole_end:
- popw %es
- popw %ds
- popaw
- ret
+ popw %es
+ popw %ds
+ popaw
+ ret
/*
* memconsole_log_char
@@ -327,55 +274,55 @@ setup_memconsole_end:
*/
memconsole_log_char:
- pushaw
- pushw %ds
- pushw %es
- pushw %fs
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- pushw BDA_EBDA /* push word at 0x0e */
- popw %es /* es = EBDA_SEG */
- movw %ax, %si /* %si = %al = byte to write */
- movl %cs:memconsole_buffer_start, %ebp
- movw %cs:memconsole_ebda_deadbabe_offset, %di
- addw $MEMCONSOLE_ENDINDEX_OFF, %di /* %di points to char pos */
- orl %ebp, %ebp
- jz memconsole_log_tail /* bufptr==0, no logging */
- movw %es:(%di), %bx /* bx = current position in buffer */
- cmpw $MEMCONSOLE_BUFFER_SIZE, %bx /* at end of buffer? */
- jnc memconsole_log_tail /* don't log any more if so */
- cmpb $0xd, %al /* is the char CR? */
- jz memconsole_log_tail /* if so, ignore it */
- cmpb $0x8, %al /* is the char backspace? */
- jnz memconsole_update_fsbase /* if not, log char as usual... */
- orw %bx, %bx /* make sure ptr isn't already zero */
- jz memconsole_log_tail /* if so, bail */
- decw %bx /* else point to previous character */
- jmp memconsole_update_end_ptr /* and go directly to save it */
+ pushaw
+ pushw %ds
+ pushw %es
+ pushw %fs
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ pushw BDA_EBDA /* push word at 0x0e */
+ popw %es /* es = EBDA_SEG */
+ movw %ax, %si /* %si = %al = byte to write */
+ movl %cs:memconsole_buffer_start, %ebp
+ movw %cs:memconsole_ebda_deadbabe_offset, %di
+ addw $MEMCONSOLE_ENDINDEX_OFF, %di /* %di points to char pos */
+ orl %ebp, %ebp
+ jz memconsole_log_tail /* bufptr==0, no logging */
+ movw %es:(%di), %bx /* bx = current position in buffer */
+ cmpw $MEMCONSOLE_BUFFER_SIZE, %bx /* at end of buffer? */
+ jnc memconsole_log_tail /* don't log any more if so */
+ cmpb $0xd, %al /* is the char CR? */
+ jz memconsole_log_tail /* if so, ignore it */
+ cmpb $0x8, %al /* is the char backspace? */
+ jnz memconsole_update_fsbase /* if not, log char as usual... */
+ orw %bx, %bx /* make sure ptr isn't already zero */
+ jz memconsole_log_tail /* if so, bail */
+ decw %bx /* else point to previous character */
+ jmp memconsole_update_end_ptr /* and go directly to save it */
memconsole_update_fsbase:
- movl $0xc0000100, %ecx /* ecx = IA32_FS_BASE (AMD64+) */
- rdmsr /* read what was there before */
- pushl %eax /* save away previous FS_BASE eax */
- pushl %edx /* save away previous FS_BASE edx */
- xorl %edx, %edx /* clear high 32 bits */
- movl %ebp, %eax /* eax = memconsole buffer start */
- wrmsr /* fs_base = memconsole buffer start */
- movw %si, %ax /* %ax = saved value on entry */
- movb %al, %fs:(%bx) /* log character */
- popl %edx /* restore previous FS_BASE edx */
- popl %eax /* restore previous FS_BASE eax */
- wrmsr /* write what was there before */
- incw %bx /* update character count */
+ movl $0xc0000100, %ecx /* ecx = IA32_FS_BASE (AMD64+) */
+ rdmsr /* read what was there before */
+ pushl %eax /* save away previous FS_BASE eax */
+ pushl %edx /* save away previous FS_BASE edx */
+ xorl %edx, %edx /* clear high 32 bits */
+ movl %ebp, %eax /* eax = memconsole buffer start */
+ wrmsr /* fs_base = memconsole buffer start */
+ movw %si, %ax /* %ax = saved value on entry */
+ movb %al, %fs:(%bx) /* log character */
+ popl %edx /* restore previous FS_BASE edx */
+ popl %eax /* restore previous FS_BASE eax */
+ wrmsr /* write what was there before */
+ incw %bx /* update character count */
memconsole_update_end_ptr:
- movw %bx, %es:(%di) /* save new end pointer */
- addw $2, %di /* numchars stored at next word */
- movw %bx, %es:(%di) /* save new numchar value */
+ movw %bx, %es:(%di) /* save new end pointer */
+ addw $2, %di /* numchars stored at next word */
+ movw %bx, %es:(%di) /* save new numchar value */
memconsole_log_tail:
- popw %fs
- popw %es
- popw %ds
- popaw
- ret
+ popw %fs
+ popw %es
+ popw %ds
+ popaw
+ ret
/* sgabioslog_setup_ebda
*
@@ -395,40 +342,40 @@ memconsole_log_tail:
*/
sgabioslog_setup_ebda:
- pushf
- pushaw
- pushw %ds
- pushw %es
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movw BDA_EBDA, %ax /* ax = old ebda segment from 0x0e */
- subw $SGABIOS_EBDA_DELTA, %ax
- movw %ax, %es /* es = new EBDA segment start */
- cmpw $EBDA_MIN_SEG, %ax /* is there room for the allocation? */
- jc sgabioslog_setup_ebda_tail /* if not, don't change anything */
- cli /* paranoid in case irq uses EBDA */
- movw %ax, BDA_EBDA /* save new EBDA segment start */
- subw $SGABIOS_EBDA_KB, BDA_MEM_SIZE /* subtract extra allocation */
- movw %ax, %ds /* ds = new EBDA segment start */
- movw $SGABIOS_EBDA_BYTES, %si /* si = offset of first byte to move */
- movzbw (%si), %cx /* cx = number of KB in EBDA */
- addb $SGABIOS_EBDA_KB, (%si) /* update EBDA size in kb */
- shlw $10, %cx /* cx = KB * 1024 = bytes in EBDA */
- movw %cx, %cs:sgabios_ebda_logbuf_offset /* new ebda space */
- xorw %di, %di /* di = new EBDA start */
- cld
- rep
- movsb /* move ebda by SGABIOS_EBDA_BYTES */
- movw %cs:sgabios_ebda_logbuf_offset, %bx /* bx = new buffer */
- movl $SGABIOS_EBDA_SIGNATURE, (%bx) /* setup signature */
- movw $SGABIOS_EBDA_BYTES, 4(%bx) /* bytes in new ebda buffer */
- movw $0, 6(%bx) /* next log index, new ebda buffer */
+ pushf
+ pushaw
+ pushw %ds
+ pushw %es
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movw BDA_EBDA, %ax /* ax = old ebda segment from 0x0e */
+ subw $SGABIOS_EBDA_DELTA, %ax
+ movw %ax, %es /* es = new EBDA segment start */
+ cmpw $EBDA_MIN_SEG, %ax /* is there room for the allocation? */
+ jc sgabioslog_setup_ebda_tail /* if not, don't change anything */
+ cli /* paranoid in case irq uses EBDA */
+ movw %ax, BDA_EBDA /* save new EBDA segment start */
+ subw $SGABIOS_EBDA_KB, BDA_MEM_SIZE /* subtract extra allocation */
+ movw %ax, %ds /* ds = new EBDA segment start */
+ movw $SGABIOS_EBDA_BYTES, %si /* si = offset of first byte to move */
+ movzbw (%si), %cx /* cx = number of KB in EBDA */
+ addb $SGABIOS_EBDA_KB, (%si) /* update EBDA size in kb */
+ shlw $10, %cx /* cx = KB * 1024 = bytes in EBDA */
+ movw %cx, %cs:sgabios_ebda_logbuf_offset /* new ebda space */
+ xorw %di, %di /* di = new EBDA start */
+ cld
+ rep
+ movsb /* move ebda by SGABIOS_EBDA_BYTES */
+ movw %cs:sgabios_ebda_logbuf_offset, %bx /* bx = new buffer */
+ movl $SGABIOS_EBDA_SIGNATURE, (%bx) /* setup signature */
+ movw $SGABIOS_EBDA_BYTES, 4(%bx) /* bytes in new ebda buffer */
+ movw $0, 6(%bx) /* next log index, new ebda buffer */
sgabioslog_setup_ebda_tail:
- popw %es
- popw %ds
- popaw
- popf
- ret
+ popw %es
+ popw %ds
+ popaw
+ popf
+ ret
/*
* sgabioslog_save_char
@@ -444,38 +391,38 @@ sgabioslog_setup_ebda_tail:
*/
sgabioslog_save_char:
- pushaw
- pushw %ds
- pushw %es
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- pushw BDA_EBDA /* push word at 0x0e */
- popw %es /* es = EBDA_SEG */
- movw %cs:sgabios_ebda_logbuf_offset, %di
- orw %di, %di /* is offset zero? */
- jz sgabioslog_save_tail /* if so, bail */
- cmpl $SGABIOS_EBDA_SIGNATURE, %es:(%di)
- jnz sgabioslog_save_tail /* bail if magic not found */
- movw %es:6(%di), %bx /* bx = index of next char output */
- movb %al, %es:SGABIOS_EBDA_LOG_START(%bx,%di) /* store character */
- movzbw %bl, %ax /* %ax = next cursor buffer index */
- shlw $1, %ax /* %ax = offset to cursor storage */
- call get_current_cursor /* %dh = row, %dl = column */
- addw $SGABIOS_EBDA_POS_START, %di /* cursor storage */
- addw %ax, %di /* %di = next cursor storage offset */
- movw %dx, %es:(%di) /* save position for logged char */
- incw %bx /* point to next char to log */
- cmpw $SGABIOS_EBDA_LOG_SIZE, %bx
- jnz sgabioslog_save_index
- xorw %bx, %bx /* wrap around to start */
+ pushaw
+ pushw %ds
+ pushw %es
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ pushw BDA_EBDA /* push word at 0x0e */
+ popw %es /* es = EBDA_SEG */
+ movw %cs:sgabios_ebda_logbuf_offset, %di
+ orw %di, %di /* is offset zero? */
+ jz sgabioslog_save_tail /* if so, bail */
+ cmpl $SGABIOS_EBDA_SIGNATURE, %es:(%di)
+ jnz sgabioslog_save_tail /* bail if magic not found */
+ movw %es:6(%di), %bx /* bx = index of next char output */
+ movb %al, %es:SGABIOS_EBDA_LOG_START(%bx,%di) /* store character */
+ movzbw %bl, %ax /* %ax = next cursor buffer index */
+ shlw $1, %ax /* %ax = offset to cursor storage */
+ call get_current_cursor /* %dh = row, %dl = column */
+ addw $SGABIOS_EBDA_POS_START, %di /* cursor storage */
+ addw %ax, %di /* %di = next cursor storage offset */
+ movw %dx, %es:(%di) /* save position for logged char */
+ incw %bx /* point to next char to log */
+ cmpw $SGABIOS_EBDA_LOG_SIZE, %bx
+ jnz sgabioslog_save_index
+ xorw %bx, %bx /* wrap around to start */
sgabioslog_save_index:
- movw %cs:sgabios_ebda_logbuf_offset, %di
- movw %bx, %es:6(%di) /* save new index */
+ movw %cs:sgabios_ebda_logbuf_offset, %di
+ movw %bx, %es:6(%di) /* save new index */
sgabioslog_save_tail:
- popw %es
- popw %ds
- popaw
- ret
+ popw %es
+ popw %ds
+ popaw
+ ret
/*
* sgabioslog_get_char
@@ -492,63 +439,63 @@ sgabioslog_save_tail:
*/
sgabioslog_get_char:
- pushaw
- movw %sp, %bp
- movb $0, 14(%bp) /* %al on stack = 0 */
- pushw %ds
- pushw %es
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- pushw BDA_EBDA /* push word at 0x0e */
- popw %es /* es = EBDA_SEG */
- movw %cs:sgabios_ebda_logbuf_offset, %di
- orw %di, %di
- jz sgabioslog_get_tail /* offset==0, no logging */
- cmpl $SGABIOS_EBDA_SIGNATURE, %es:(%di)
- jnz sgabioslog_get_tail /* bail if magic not found */
- call get_current_cursor /* dh = row, dl = col */
- std /* scan backwards in mem */
- movw %es:6(%di), %bx /* bx = index of next char output */
- decw %bx /* %bx = offset of last char in buf */
- jnc sgabioslog_got_pos
- addw $SGABIOS_EBDA_LOG_SIZE, %bx /* bx position wrap around */
+ pushaw
+ movw %sp, %bp
+ movb $0, 14(%bp) /* %al on stack = 0 */
+ pushw %ds
+ pushw %es
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ pushw BDA_EBDA /* push word at 0x0e */
+ popw %es /* es = EBDA_SEG */
+ movw %cs:sgabios_ebda_logbuf_offset, %di
+ orw %di, %di
+ jz sgabioslog_get_tail /* offset==0, no logging */
+ cmpl $SGABIOS_EBDA_SIGNATURE, %es:(%di)
+ jnz sgabioslog_get_tail /* bail if magic not found */
+ call get_current_cursor /* dh = row, dl = col */
+ std /* scan backwards in mem */
+ movw %es:6(%di), %bx /* bx = index of next char output */
+ decw %bx /* %bx = offset of last char in buf */
+ jnc sgabioslog_got_pos
+ addw $SGABIOS_EBDA_LOG_SIZE, %bx /* bx position wrap around */
sgabioslog_got_pos:
- movw %bx, %ax /* %ax = last cursor pos written */
- shlw $1, %ax /* %ax = offset of last cursor pos */
- addw $SGABIOS_EBDA_POS_START, %di /* %di = first cursor position */
- addw %ax, %di /* %di = offset in ebda */
- movw %dx, %ax /* %ax = cursor pos to compare */
- movw %bx, %cx /* %cx = positions before wrap */
- jcxz sgabioslog_cmp_wrap /* if zero, try from end next */
- repnz
- scasw /* search until position match */
- addw $2, %di /* scasd always decrements di, undo */
- cmpw %ax, %es:(%di) /* did it really match? */
- jz sgabioslog_cursor_match /* if so, do something */
+ movw %bx, %ax /* %ax = last cursor pos written */
+ shlw $1, %ax /* %ax = offset of last cursor pos */
+ addw $SGABIOS_EBDA_POS_START, %di /* %di = first cursor position */
+ addw %ax, %di /* %di = offset in ebda */
+ movw %dx, %ax /* %ax = cursor pos to compare */
+ movw %bx, %cx /* %cx = positions before wrap */
+ jcxz sgabioslog_cmp_wrap /* if zero, try from end next */
+ repnz
+ scasw /* search until position match */
+ addw $2, %di /* scasd always decrements di, undo */
+ cmpw %ax, %es:(%di) /* did it really match? */
+ jz sgabioslog_cursor_match /* if so, do something */
sgabioslog_cmp_wrap:
- movw %cs:sgabios_ebda_logbuf_offset, %di
- addw $SGABIOS_EBDA_POS_LAST, %di /* %di = last cursor storage */
- movw $SGABIOS_EBDA_LOG_SIZE, %cx /* %cx = compare all positions */
- repnz
- scasw /* search until position match */
- addw $2, %di /* scasd always decrements di, undo */
- cmpw %ax, %es:(%di) /* did it really match? */
- jnz sgabioslog_get_tail /* if not, bail */
+ movw %cs:sgabios_ebda_logbuf_offset, %di
+ addw $SGABIOS_EBDA_POS_LAST, %di /* %di = last cursor storage */
+ movw $SGABIOS_EBDA_LOG_SIZE, %cx /* %cx = compare all positions */
+ repnz
+ scasw /* search until position match */
+ addw $2, %di /* scasd always decrements di, undo */
+ cmpw %ax, %es:(%di) /* did it really match? */
+ jnz sgabioslog_get_tail /* if not, bail */
sgabioslog_cursor_match:
- /* %di contains the EBDA offset of the matching position */
- /* convert this into a memconsole offset */
- subw $512, %di /* take off the storage offset */
- subw %cs:sgabios_ebda_logbuf_offset, %di /* and ebda offset */
- shrw $1, %di /* %di = char position index */
- addw %cs:sgabios_ebda_logbuf_offset, %di /* add back ebda offset */
- addw $SGABIOS_EBDA_LOG_START, %di /* and add back log offset */
- movb %es:(%di), %al /* get related saved character */
- movb %al, 14(%bp) /* %al on stack = logged char */
+ /* %di contains the EBDA offset of the matching position */
+ /* convert this into a memconsole offset */
+ subw $512, %di /* take off the storage offset */
+ subw %cs:sgabios_ebda_logbuf_offset, %di /* and ebda offset */
+ shrw $1, %di /* %di = char position index */
+ addw %cs:sgabios_ebda_logbuf_offset, %di /* add back ebda offset */
+ addw $SGABIOS_EBDA_LOG_START, %di /* and add back log offset */
+ movb %es:(%di), %al /* get related saved character */
+ movb %al, 14(%bp) /* %al on stack = logged char */
sgabioslog_get_tail:
- popw %es
- popw %ds
- popaw
- ret
+ popw %es
+ popw %ds
+ popaw
+ ret
/*
* multibyteinput
@@ -574,139 +521,139 @@ sgabioslog_get_tail:
* FIXME: all the low bytes are now zero, get rid of them?
*/
multibyteinput:
- .byte 0x3b /* F1 */
- .asciz "[[A" /* F1/screen */
+ .byte 0x3b /* F1 */
+ .asciz "[[A" /* F1/screen */
- .byte 0x3b /* F1 */
- .asciz "OP" /* F1/xterm/ansi */
+ .byte 0x3b /* F1 */
+ .asciz "OP" /* F1/xterm/ansi */
- .byte 0x3b /* F1 */
- .asciz "[11~" /* F1/vt400 */
+ .byte 0x3b /* F1 */
+ .asciz "[11~" /* F1/vt400 */
- .byte 0x3c /* F2 */
- .asciz "[[B" /* F2/screen */
+ .byte 0x3c /* F2 */
+ .asciz "[[B" /* F2/screen */
- .byte 0x3c /* F2 */
- .asciz "OQ" /* F2/xterm/ansi */
+ .byte 0x3c /* F2 */
+ .asciz "OQ" /* F2/xterm/ansi */
- .byte 0x3c /* F2 */
- .asciz "[12~" /* F2/vt400 */
+ .byte 0x3c /* F2 */
+ .asciz "[12~" /* F2/vt400 */
- .byte 0x3d /* F3 */
- .asciz "[[C" /* F3/screen */
+ .byte 0x3d /* F3 */
+ .asciz "[[C" /* F3/screen */
- .byte 0x3d /* F3 */
- .asciz "OR" /* F3/xterm/ansi */
+ .byte 0x3d /* F3 */
+ .asciz "OR" /* F3/xterm/ansi */
- .byte 0x3d /* F3 */
- .asciz "[13~" /* F3/vt400 */
+ .byte 0x3d /* F3 */
+ .asciz "[13~" /* F3/vt400 */
- .byte 0x3e /* F4 */
- .asciz "[[D" /* F4/screen */
+ .byte 0x3e /* F4 */
+ .asciz "[[D" /* F4/screen */
- .byte 0x3e /* F4 */
- .asciz "OS" /* F4/xterm/ansi */
+ .byte 0x3e /* F4 */
+ .asciz "OS" /* F4/xterm/ansi */
- .byte 0x3e /* F4 */
- .asciz "[14~" /* F4/vt400 */
+ .byte 0x3e /* F4 */
+ .asciz "[14~" /* F4/vt400 */
- .byte 0x3f /* F5 */
- .asciz "[[E" /* F5/screen */
+ .byte 0x3f /* F5 */
+ .asciz "[[E" /* F5/screen */
- .byte 0x3f /* F5 */
- .asciz "[15~" /* F5/xterm */
+ .byte 0x3f /* F5 */
+ .asciz "[15~" /* F5/xterm */
- .byte 0x3f /* F5 */
- .asciz "OT" /* F5/ansi */
+ .byte 0x3f /* F5 */
+ .asciz "OT" /* F5/ansi */
- .byte 0x40 /* F6 */
- .asciz "[17~" /* F6/screen/vt220/xterm/vt400 */
+ .byte 0x40 /* F6 */
+ .asciz "[17~" /* F6/screen/vt220/xterm/vt400 */
- .byte 0x40 /* F6 */
- .asciz "OU" /* F6/ansi */
+ .byte 0x40 /* F6 */
+ .asciz "OU" /* F6/ansi */
- .byte 0x41 /* F7 */
- .asciz "[18~" /* F7/screen/vt220/xterm/vt400 */
+ .byte 0x41 /* F7 */
+ .asciz "[18~" /* F7/screen/vt220/xterm/vt400 */
- .byte 0x41 /* F7 */
- .asciz "OV" /* F7/ansi */
+ .byte 0x41 /* F7 */
+ .asciz "OV" /* F7/ansi */
- .byte 0x42 /* F8 */
- .asciz "[19~" /* F8/screen/vt220/xterm/vt400 */
+ .byte 0x42 /* F8 */
+ .asciz "[19~" /* F8/screen/vt220/xterm/vt400 */
- .byte 0x42 /* F8 */
- .asciz "OW" /* F8/ansi */
+ .byte 0x42 /* F8 */
+ .asciz "OW" /* F8/ansi */
- .byte 0x43 /* F9 */
- .asciz "[20~" /* F9/screen/vt220/xterm/vt400 */
+ .byte 0x43 /* F9 */
+ .asciz "[20~" /* F9/screen/vt220/xterm/vt400 */
- .byte 0x43 /* F9 */
- .asciz "OX" /* F9/ansi */
+ .byte 0x43 /* F9 */
+ .asciz "OX" /* F9/ansi */
- .byte 0x44 /* F10 */
- .asciz "[21~" /* F10/screen/vt220/xterm/vt400 */
+ .byte 0x44 /* F10 */
+ .asciz "[21~" /* F10/screen/vt220/xterm/vt400 */
- .byte 0x44 /* F10 */
- .asciz "OY" /* F10/ansi */
+ .byte 0x44 /* F10 */
+ .asciz "OY" /* F10/ansi */
- .byte 0x85 /* F11 */
- .asciz "[23~" /* F11/screen/xterm/vt400 */
+ .byte 0x85 /* F11 */
+ .asciz "[23~" /* F11/screen/xterm/vt400 */
- .byte 0x85 /* F11 */
- .asciz "OZ" /* F11/ansi */
+ .byte 0x85 /* F11 */
+ .asciz "OZ" /* F11/ansi */
- .byte 0x86 /* F12 */
- .asciz "[24~" /* F12/screen/xterm/vt400 */
+ .byte 0x86 /* F12 */
+ .asciz "[24~" /* F12/screen/xterm/vt400 */
- .byte 0x52 /* Insert */
- .asciz "[2~" /* Insert/screen/vt102/xterm */
+ .byte 0x52 /* Insert */
+ .asciz "[2~" /* Insert/screen/vt102/xterm */
- .byte 0x53 /* Delete */
- .asciz "[3~" /* Delete/screen/vt102/xterm */
+ .byte 0x53 /* Delete */
+ .asciz "[3~" /* Delete/screen/vt102/xterm */
- .byte 0x4b /* Left */
- .asciz "OD" /* Left/screen/vt102 */
+ .byte 0x4b /* Left */
+ .asciz "OD" /* Left/screen/vt102 */
- .byte 0x4b /* Left */
- .asciz "[D" /* Left/xterm */
+ .byte 0x4b /* Left */
+ .asciz "[D" /* Left/xterm */
- .byte 0x47 /* Home */
- .asciz "[1~" /* Home/screen/vt102 */
+ .byte 0x47 /* Home */
+ .asciz "[1~" /* Home/screen/vt102 */
- .byte 0x47 /* Home */
- .asciz "[H" /* Home/xterm */
+ .byte 0x47 /* Home */
+ .asciz "[H" /* Home/xterm */
- .byte 0x4f /* End */
- .asciz "[4~" /* End/screen/vt102 */
+ .byte 0x4f /* End */
+ .asciz "[4~" /* End/screen/vt102 */
- .byte 0x4f /* End */
- .asciz "[F" /* End/xterm */
+ .byte 0x4f /* End */
+ .asciz "[F" /* End/xterm */
- .byte 0x48 /* Up */
- .asciz "OA" /* Up/screen/vt102 app */
+ .byte 0x48 /* Up */
+ .asciz "OA" /* Up/screen/vt102 app */
- .byte 0x48 /* Up */
- .asciz "[A" /* Up/xterm/vt102 ansi */
+ .byte 0x48 /* Up */
+ .asciz "[A" /* Up/xterm/vt102 ansi */
- .byte 0x50 /* Down */
- .asciz "OB" /* Down/screen/vt102 app */
+ .byte 0x50 /* Down */
+ .asciz "OB" /* Down/screen/vt102 app */
- .byte 0x50 /* Down */
- .asciz "[B" /* Down/xterm/vt102 ansi */
+ .byte 0x50 /* Down */
+ .asciz "[B" /* Down/xterm/vt102 ansi */
- .byte 0x49 /* PageUp */
- .asciz "[5~" /* PageUp/screen/vt102/xterm */
+ .byte 0x49 /* PageUp */
+ .asciz "[5~" /* PageUp/screen/vt102/xterm */
- .byte 0x51 /* PageDown */
- .asciz "[6~" /* PageDown/screen/vt102/xterm */
+ .byte 0x51 /* PageDown */
+ .asciz "[6~" /* PageDown/screen/vt102/xterm */
- .byte 0x4d /* Right */
- .asciz "OC" /* Right/screen/vt102 app */
+ .byte 0x4d /* Right */
+ .asciz "OC" /* Right/screen/vt102 app */
- .byte 0x4d /* Right */
- .asciz "[C" /* Right/xterm/vt102 ansi */
+ .byte 0x4d /* Right */
+ .asciz "[C" /* Right/xterm/vt102 ansi */
- .byte 0 /* end of table marker */
+ .byte 0 /* end of table marker */
/* init_serial_port
*
@@ -717,38 +664,38 @@ multibyteinput:
*/
init_serial_port:
- pushw %ax
- pushw %dx
- pushw %bx
- movw %cs:serial_port_base_address, %dx
- addw $IER_OFFSET, %dx
- xorb %al, %al
- outb %al, %dx /* disable all serial interrupts */
- addw $(LCR_OFFSET - IER_OFFSET), %dx /* LCR */
- movb $(LCR_VALUE|LCR_DLAB), %al
- outb %al, %dx /* enable divisor access */
- movw %cs:serial_port_base_address, %dx
- movw $(PORT_DIVISOR/PORT_SPEED), %bx
- movb %bl, %al /* al = lsb of divisor */
- outb %al, %dx /* set divisor latch lsb */
- movb %bh, %al /* al = msb of divisor */
- incw %dx
- outb %al, %dx /* set divisor latch msb */
- movw %cs:serial_port_base_address, %dx
- addw $LCR_OFFSET, %dx
- movb $LCR_VALUE, %al
- outb %al, %dx /* disable divisor access */
- addw $(MCR_OFFSET - LCR_OFFSET), %dx /* MCR */
- movb $MCR_DTRRTS, %al
- outb %al, %dx /* enable DTR + RTS */
- movw %cs:serial_port_base_address, %dx
- addw $FCR_OFFSET, %dx
- movb $FCR_FIFO_ENABLE, %al
- outb %al, %dx /* enable FIFOs */
- popw %bx
- popw %dx
- popw %ax
- ret
+ pushw %ax
+ pushw %dx
+ pushw %bx
+ movw %cs:serial_port_base_address, %dx
+ addw $IER_OFFSET, %dx
+ xorb %al, %al
+ outb %al, %dx /* disable all serial interrupts */
+ addw $(LCR_OFFSET - IER_OFFSET), %dx /* LCR */
+ movb $(LCR_VALUE|LCR_DLAB), %al
+ outb %al, %dx /* enable divisor access */
+ movw %cs:serial_port_base_address, %dx
+ movw $(PORT_DIVISOR/PORT_SPEED), %bx
+ movb %bl, %al /* al = lsb of divisor */
+ outb %al, %dx /* set divisor latch lsb */
+ movb %bh, %al /* al = msb of divisor */
+ incw %dx
+ outb %al, %dx /* set divisor latch msb */
+ movw %cs:serial_port_base_address, %dx
+ addw $LCR_OFFSET, %dx
+ movb $LCR_VALUE, %al
+ outb %al, %dx /* disable divisor access */
+ addw $(MCR_OFFSET - LCR_OFFSET), %dx /* MCR */
+ movb $MCR_DTRRTS, %al
+ outb %al, %dx /* enable DTR + RTS */
+ movw %cs:serial_port_base_address, %dx
+ addw $FCR_OFFSET, %dx
+ movb $FCR_FIFO_ENABLE, %al
+ outb %al, %dx /* enable FIFOs */
+ popw %bx
+ popw %dx
+ popw %ax
+ ret
/* get_serial_lsr
@@ -761,12 +708,12 @@ init_serial_port:
*/
get_serial_lsr:
- movw %cs:serial_port_base_address, %dx
- addw $LSR_OFFSET, %dx
- inb %dx, %al
- cmpb $0xff, %al
- ret
-
+ movw %cs:serial_port_base_address, %dx
+ addw $LSR_OFFSET, %dx
+ inb %dx, %al
+ cmpb $0xff, %al
+ ret
+
/*
* get_byte
*
@@ -777,39 +724,39 @@ get_serial_lsr:
*/
get_byte:
- pushw %dx
- pushw %bx
+ pushw %dx
+ pushw %bx
next_serial_char:
- call get_serial_lsr /* get serial lsr in %al */
- jz get_byte_tail /* no port present... */
- testb $1, %al /* check bit 0 of LSR for data available */
- jz get_byte_tail /* no input waiting */
- /* new character found on serial port */
- /* convert it to a scancode */
- movw %cs:serial_port_base_address, %dx
- inb %dx, %al /* al = serial input char */
- testb $0x80, %al /* non-ascii char received? */
- jnz next_serial_char /* throw char away */
- movb %al, %dl /* dl = character read */
- pushw %ds
- pushw %cs
- popw %ds /* ds = cs */
- movw $ascii2scan, %bx /* table to translate ascii->scan */
- xlatb /* translate char to scancode */
- popw %ds
- /* shift status is ignored at this point, may be used later */
- andb $0x7f, %al /* strip shift status from table */
- movb %al, %ah /* scancode goes in high byte */
- movb %dl, %al /* "translated" ascii in lower byte */
- cmpb $0x7f, %al /* Did the user transmit ascii DEL? */
- jnz get_byte_not_del /* if not, don't do anything to al */
- movb $0x08, %al /* else delete becomes backspace */
+ call get_serial_lsr /* get serial lsr in %al */
+ jz get_byte_tail /* no port present... */
+ testb $1, %al /* bit 0 of LSR = 1 = data available */
+ jz get_byte_tail /* no input waiting */
+ /* new character found on serial port */
+ /* convert it to a scancode */
+ movw %cs:serial_port_base_address, %dx
+ inb %dx, %al /* al = serial input char */
+ testb $0x80, %al /* non-ascii char received? */
+ jnz next_serial_char /* throw char away */
+ movb %al, %dl /* dl = character read */
+ pushw %ds
+ pushw %cs
+ popw %ds /* ds = cs */
+ movw $ascii2scan, %bx /* table to translate ascii->scan */
+ xlatb /* translate char to scancode */
+ popw %ds
+ /* shift status is ignored at this point, may be used later */
+ andb $0x7f, %al /* strip shift status from table */
+ movb %al, %ah /* scancode goes in high byte */
+ movb %dl, %al /* "translated" ascii in lower byte */
+ cmpb $0x7f, %al /* Did the user transmit ascii DEL? */
+ jnz get_byte_not_del /* if not, don't do anything to al */
+ movb $0x08, %al /* else delete becomes backspace */
get_byte_not_del:
- testw %ax, %ax /* clear zero flag */
+ testw %ax, %ax /* clear zero flag */
get_byte_tail:
- popw %bx
- popw %dx
- ret
+ popw %bx
+ popw %dx
+ ret
/*
* poll_byte
@@ -822,14 +769,14 @@ get_byte_tail:
*/
poll_byte:
- pushw %cx
- xorw %cx, %cx
+ pushw %cx
+ xorw %cx, %cx
poll_byte_retry:
- inb $0xed, %al
- call get_byte
- loopz poll_byte_retry /* repeat while zf set or cx != 0 */
- popw %cx
- ret
+ inb $0xed, %al
+ call get_byte
+ loopz poll_byte_retry /* repeat while zf set or cx != 0 */
+ popw %cx
+ ret
/*
* get_multibyte
@@ -842,59 +789,59 @@ poll_byte_retry:
*
*/
get_multibyte:
- pushw %bp /* bp points to temp buffer on stack */
- pushw %bx /* bx points to multibyteinput table */
- pushw %cx /* cx will count chars */
- pushw %ax /* ax will receive chars */
- pushl $0 /* make space on stack for 4 chars */
- xorw %cx, %cx /* cx = 0 */
- movw %sp, %bp /* point bp at temp data */
- call poll_byte /* is a character waiting? */
- jz get_multibyte_tail /* if not, bail */
+ pushw %bp /* bp points to temp buffer on stack */
+ pushw %bx /* bx points to multibyteinput table */
+ pushw %cx /* cx will count chars */
+ pushw %ax /* ax will receive chars */
+ pushl $0 /* make space on stack for 4 chars */
+ xorw %cx, %cx /* cx = 0 */
+ movw %sp, %bp /* point bp at temp data */
+ call poll_byte /* is a character waiting? */
+ jz get_multibyte_tail /* if not, bail */
get_multibyte_store:
- movb %al, (%bp) /* store char received */
- incb %cl /* mark one char received */
- incw %bp /* point to next char */
- cmpb $4, %cl /* got enough chars? */
- jz got_multibyte /* no strings longer than 4 chars */
- call poll_byte /* is another char waiting? */
- jnz get_multibyte_store /* store a new one if it's there */
+ movb %al, (%bp) /* store char received */
+ incb %cl /* mark one char received */
+ incw %bp /* point to next char */
+ cmpb $4, %cl /* got enough chars? */
+ jz got_multibyte /* no strings longer than 4 chars */
+ call poll_byte /* is another char waiting? */
+ jnz get_multibyte_store /* store a new one if it's there */
got_multibyte:
- movw $multibyteinput, %bx /* point to first scancode */
+ movw $multibyteinput, %bx /* point to first scancode */
got_multibyte_findkey:
- movw %sp, %bp /* bp = start of buffer */
- movb %cs:(%bx), %ah /* ah = scancode */
- incw %bx /* bx = start of test string */
- orb %ah, %ah /* is it zero? */
- jz get_multibyte_tail /* if so, bail, key not found */
+ movw %sp, %bp /* bp = start of buffer */
+ movb %cs:(%bx), %ah /* ah = scancode */
+ incw %bx /* bx = start of test string */
+ orb %ah, %ah /* is it zero? */
+ jz get_multibyte_tail /* if so, bail, key not found */
got_multibyte_nextchar:
- movb %cs:(%bx), %ch /* ch = test char to compare */
- incw %bx /* point to next char */
- orb %ch, %ch /* is char to compare NUL? */
- jz got_multibyte_key /* matched to end of a string! */
- cmpb %ch, (%bp) /* is input tmp buf equal to test char? */
- jnz got_multibyte_try_next_key
- /* note: expected that test string will be nul before input string */
- /* no attempt is made to ensure no more than 4 bytes stack read */
- incw %bp /* point to next input */
- jmp got_multibyte_nextchar
-got_multibyte_try_next_key: /* align to next scancode/ascii pair */
- movb %cs:(%bx), %ch /* ch = test char to compare */
- incw %bx /* point to next char */
- orb %ch, %ch /* is char to compare NUL? */
- jnz got_multibyte_try_next_key
- jmp got_multibyte_findkey
+ movb %cs:(%bx), %ch /* ch = test char to compare */
+ incw %bx /* point to next char */
+ orb %ch, %ch /* is char to compare NUL? */
+ jz got_multibyte_key /* matched to end of a string! */
+ cmpb %ch, (%bp) /* input tmp buf equal to test char? */
+ jnz got_multibyte_try_next_key
+ /* note: expected that test string will be nul before input string */
+ /* no attempt is made to ensure no more than 4 bytes stack read */
+ incw %bp /* point to next input */
+ jmp got_multibyte_nextchar
+got_multibyte_try_next_key: /* align to next scancode/ascii pair */
+ movb %cs:(%bx), %ch /* ch = test char to compare */
+ incw %bx /* point to next char */
+ orb %ch, %ch /* is char to compare NUL? */
+ jnz got_multibyte_try_next_key
+ jmp got_multibyte_findkey
got_multibyte_key:
- xorb %al, %al /* ascii value = 0 for special keys */
- movw %sp, %bp
- movw %ax, 4(%bp) /* overwrite old %ax value with new key */
+ xorb %al, %al /* ascii value = 0 for special keys */
+ movw %sp, %bp
+ movw %ax, 4(%bp) /* overwrite old %ax value with key */
get_multibyte_tail:
- addw $4, %sp /* pop temp space */
- popw %ax
- popw %cx
- popw %bx
- popw %bp
- ret
+ addw $4, %sp /* pop temp space */
+ popw %ax
+ popw %cx
+ popw %bx
+ popw %bp
+ ret
/*
* send_byte
@@ -906,25 +853,25 @@ get_multibyte_tail:
*/
send_byte:
- pushw %ax
- pushw %dx
- pushw %cx
- testb $0x80, %al /* don't send non-ascii chars */
- jnz send_tail /* these should be translated earlier */
- movb %al, %ah /* save char to output in %ah */
- movw $0xFFF0, %cx /* only retry 65520 times */
+ pushw %ax
+ pushw %dx
+ pushw %cx
+ testb $0x80, %al /* don't send non-ascii chars */
+ jnz send_tail /* these should be translated earlier */
+ movb %al, %ah /* save char to output in %ah */
+ movw $0xFFF0, %cx /* only retry 65520 times */
serial_ready_test:
- call get_serial_lsr /* get serial lsr in %al */
- testb $TRANSMIT_READY_BIT, %al
- loopz serial_ready_test /* if !TRANSMIT_READY_BIT, loop while cx!=0 */
- movb %ah, %al
- movw %cs:serial_port_base_address, %dx
- outb %al, %dx
+ call get_serial_lsr /* get serial lsr in %al */
+ testb $TRANSMIT_READY_BIT, %al
+ loopz serial_ready_test /* if !tx ready, loop while cx!=0 */
+ movb %ah, %al
+ movw %cs:serial_port_base_address, %dx
+ outb %al, %dx
send_tail:
- popw %cx
- popw %dx
- popw %ax
- ret
+ popw %cx
+ popw %dx
+ popw %ax
+ ret
/*
* translate_char
@@ -939,24 +886,24 @@ send_tail:
*/
translate_char:
- pushw %bx
- pushw %ds
- pushw %cs
- popw %ds /* ds = cs */
- testb $0x80, %al
- jz translate_char_ctrl
- andb $0x7f, %al
- movw $high2ascii, %bx
- xlatb
+ pushw %bx
+ pushw %ds
+ pushw %cs
+ popw %ds /* ds = cs */
+ testb $0x80, %al
+ jz translate_char_ctrl
+ andb $0x7f, %al
+ movw $high2ascii, %bx
+ xlatb
translate_char_ctrl:
- cmpb $0x20, %al
- jnc translate_char_tail
- movw $ctrl2ascii, %bx
- xlatb
+ cmpb $0x20, %al
+ jnc translate_char_tail
+ movw $ctrl2ascii, %bx
+ xlatb
translate_char_tail:
- popw %ds
- popw %bx
- ret
+ popw %ds
+ popw %bx
+ ret
/*
* translate_char_tty
@@ -972,17 +919,17 @@ translate_char_tail:
*/
translate_char_tty:
- cmpb $0x07, %al /* bell */
- jz translate_char_tty_tail
- cmpb $0x08, %al /* backspace */
- jz translate_char_tty_tail
- cmpb $0x0a, %al /* LF */
- jz translate_char_tty_tail
- cmpb $0x0d, %al /* CR */
- jz translate_char_tty_tail
- call translate_char
+ cmpb $0x07, %al /* bell */
+ jz translate_char_tty_tail
+ cmpb $0x08, %al /* backspace */
+ jz translate_char_tty_tail
+ cmpb $0x0a, %al /* LF */
+ jz translate_char_tty_tail
+ cmpb $0x0d, %al /* CR */
+ jz translate_char_tty_tail
+ call translate_char
translate_char_tty_tail:
- ret
+ ret
/*
* send_char
@@ -1003,10 +950,10 @@ translate_char_tty_tail:
*/
send_char:
- call sgabioslog_save_char /* save original char+pos */
- call translate_char
- jmp send_char_tty_out
- /* after ctrl translation, same as send_char_tty */
+ call sgabioslog_save_char /* save original char+pos */
+ call translate_char
+ jmp send_char_tty_out
+ /* after ctrl translation, same as send_char_tty */
/*
* send_char_tty
@@ -1030,66 +977,66 @@ send_char:
/* send character 0 - 255 in %al out through serial port */
/* increment cursor position with CR/LF/Backspace processing */
send_char_tty:
- call sgabioslog_save_char /* save original char+pos */
- call translate_char_tty
+ call sgabioslog_save_char /* save original char+pos */
+ call translate_char_tty
send_char_tty_out:
- pushw %dx
- call update_serial_cursor
- call get_current_cursor /* vga cursor in %dx */
- cmpb $0x0d, %al /* CR */
- jnz send_char_tty_nul /* if not CR, check for NUL */
- orb %dl, %dl /* already at col 0? */
- jz send_char_tty_tail /* no need to re-send CR */
+ pushw %dx
+ call update_serial_cursor
+ call get_current_cursor /* vga cursor in %dx */
+ cmpb $0x0d, %al /* CR */
+ jnz send_char_tty_nul /* if not CR, check for NUL */
+ orb %dl, %dl /* already at col 0? */
+ jz send_char_tty_tail /* no need to re-send CR */
send_char_tty_nul:
- orb %al, %al /* %al == 0 ? (nul) */
- /* more than likely, we have NUL at this point because the caller */
- /* tried to read a char using int $0x10, %ah=8, and is trying */
- /* to re-output it with different attributes - for now send nothing */
- jz send_char_tty_tail
+ orb %al, %al /* %al == 0 ? (nul) */
+ /* more than likely, we have NUL at this point because the caller */
+ /* tried to read a char using int $0x10, %ah=8, and is trying */
+ /* to re-output it with different attributes - for now send nothing */
+ jz send_char_tty_tail
send_char_tty_write:
- call memconsole_log_char /* log character sent */
- call send_byte
- cmpb $0x07, %al /* bell */
- jz send_char_tty_tail /* no cursor update for bell */
- cmpb $0x08, %al /* backspace */
- jz send_char_tty_backspace
- cmpb $0x0a, %al /* LF */
- jz send_char_tty_lf
- cmpb $0x0d, %al /* CR */
- jz send_char_tty_cr
- incb %dl
- jmp send_char_tty_tail
+ call memconsole_log_char /* log character sent */
+ call send_byte
+ cmpb $0x07, %al /* bell */
+ jz send_char_tty_tail /* no cursor update for bell */
+ cmpb $0x08, %al /* backspace */
+ jz send_char_tty_backspace
+ cmpb $0x0a, %al /* LF */
+ jz send_char_tty_lf
+ cmpb $0x0d, %al /* CR */
+ jz send_char_tty_cr
+ incb %dl
+ jmp send_char_tty_tail
send_char_tty_backspace:
- orb %dl, %dl
- jz send_char_tty_tail
- decb %dl
- jmp send_char_tty_tail
+ orb %dl, %dl
+ jz send_char_tty_tail
+ decb %dl
+ jmp send_char_tty_tail
send_char_tty_lf:
- incb %dh
- jmp send_char_tty_tail
+ incb %dh
+ jmp send_char_tty_tail
send_char_tty_cr:
- xorb %dl, %dl
+ xorb %dl, %dl
send_char_tty_tail:
- cmpb %cs:term_cols, %dl
- jc send_char_tty_check_rows
- movb %cs:term_cols, %dl
- decb %dl /* dl = cols - 1 */
+ cmpb %cs:term_cols, %dl
+ jc send_char_tty_check_rows
+ movb %cs:term_cols, %dl
+ decb %dl /* dl = cols - 1 */
send_char_tty_check_rows:
- cmpb %cs:term_rows, %dh
- jc send_char_tty_save_cursor
- movb %cs:term_rows, %dh
- decb %dh /* dh = rows - 1 */
+ cmpb %cs:term_rows, %dh
+ jc send_char_tty_save_cursor
+ movb %cs:term_rows, %dh
+ decb %dh /* dh = rows - 1 */
send_char_tty_save_cursor:
- call set_current_cursor
- pushw %ds
- pushw $BDA_SEG
- popw %ds
- /* save current position as the serial terminal position */
- /* since a character was just output at that position */
- movw %dx, BDA_SERIAL_POS
- popw %ds
- popw %dx
- ret
+ call set_current_cursor
+ pushw %ds
+ pushw $BDA_SEG
+ popw %ds
+ /* save current position as the serial terminal position */
+ /* since a character was just output at that position */
+ movw %dx, BDA_SERIAL_POS
+ popw %ds
+ popw %dx
+ ret
/*
* send_asciz_out
@@ -1103,19 +1050,19 @@ send_char_tty_save_cursor:
*/
send_asciz_out:
- pushw %ax
- pushw %si
- cld
+ pushw %ax
+ pushw %si
+ cld
send_asciz_loop:
- lodsb
- test %al,%al
- jz send_asciz_end
- call send_byte
- jmp send_asciz_loop
+ lodsb
+ test %al,%al
+ jz send_asciz_end
+ call send_byte
+ jmp send_asciz_loop
send_asciz_end:
- popw %si
- popw %ax
- ret
+ popw %si
+ popw %ax
+ ret
/*
* send_string
@@ -1129,16 +1076,16 @@ send_asciz_end:
*/
send_string:
- pushw %ax
- pushw %si
- cld
+ pushw %ax
+ pushw %si
+ cld
send_string_loop:
- lodsb
- call send_char_tty
- loop send_string_loop
- popw %si
- popw %ax
- ret
+ lodsb
+ call send_char_tty
+ loop send_string_loop
+ popw %si
+ popw %ax
+ ret
/*
* send_string
@@ -1153,21 +1100,21 @@ send_string_loop:
*/
send_attr_string:
- pushw %ax
- pushw %bx
- pushw %si
- cld
+ pushw %ax
+ pushw %bx
+ pushw %si
+ cld
send_attr_string_loop:
- lodsb
- call send_char_tty
- lodsb
- movb %al, %bl
- call send_attribute /* send attribute in %bl */
- loop send_attr_string_loop
- popw %si
- popw %bx
- popw %ax
- ret
+ lodsb
+ call send_char_tty
+ lodsb
+ movb %al, %bl
+ call send_attribute /* send attribute in %bl */
+ loop send_attr_string_loop
+ popw %si
+ popw %bx
+ popw %ax
+ ret
/*
* send_number
@@ -1181,31 +1128,31 @@ send_attr_string_loop:
*/
send_number:
- pushw %ax
- pushw %bx
- aam /* ah = al/10, al = al mod 10 */
- movw %ax, %bx /* bh = al/10, bl = al mod 10 */
- movb %bh, %al
- aam /* ah = bh/10, al = bh mod 10 */
- movb %al, %bh /* bh = 10s digit, bl = 1s digit */
- movb %ah, %al /* ah = al = 100s digit */
- testb %al, %al /* is there a 100s digit? */
- jz send_tens /* move to tens if not */
- orb $0x30, %al /* al = ascii value of digit */
- call send_byte
+ pushw %ax
+ pushw %bx
+ aam /* ah = al/10, al = al mod 10 */
+ movw %ax, %bx /* bh = al/10, bl = al mod 10 */
+ movb %bh, %al
+ aam /* ah = bh/10, al = bh mod 10 */
+ movb %al, %bh /* bh = 10s digit, bl = 1s digit */
+ movb %ah, %al /* ah = al = 100s digit */
+ testb %al, %al /* is there a 100s digit? */
+ jz send_tens /* move to tens if not */
+ orb $0x30, %al /* al = ascii value of digit */
+ call send_byte
send_tens:
- orb %bh, %ah /* bh = 10s, ah = 100s digits */
- jz send_ones /* non-zero = must send tens */
- movb %bh, %al /* al = bh = 10s digit */
- orb $0x30, %al /* al = ascii value of digit */
- call send_byte
+ orb %bh, %ah /* bh = 10s, ah = 100s digits */
+ jz send_ones /* non-zero = must send tens */
+ movb %bh, %al /* al = bh = 10s digit */
+ orb $0x30, %al /* al = ascii value of digit */
+ call send_byte
send_ones:
- movb %bl, %al /* al = bl = 1s digit */
- orb $0x30, %al /* al = ascii value of digit */
- call send_byte
- popw %bx
- popw %ax
- ret
+ movb %bl, %al /* al = bl = 1s digit */
+ orb $0x30, %al /* al = ascii value of digit */
+ call send_byte
+ popw %bx
+ popw %ax
+ ret
/*
* send_crlf
@@ -1224,13 +1171,13 @@ send_ones:
*/
send_crlf:
- pushw %ax
- movb $0x0d, %al
- call send_byte
- movb $0x0a, %al
- call send_byte
- popw %ax
- ret
+ pushw %ax
+ movb $0x0d, %al
+ call send_byte
+ movb $0x0a, %al
+ call send_byte
+ popw %ax
+ ret
/*
* send_ansi_csi
*
@@ -1241,14 +1188,14 @@ send_crlf:
* all registers preserved except flags
*/
-send_ansi_csi: /* transmit ESC [ */
- pushw %ax
- movb $0x1b, %al /* escape */
- call send_byte
- movb $0x5b, %al /* [ */
- call send_byte
- popw %ax
- ret
+send_ansi_csi: /* transmit ESC [ */
+ pushw %ax
+ movb $0x1b, %al /* escape */
+ call send_byte
+ movb $0x5b, %al /* [ */
+ call send_byte
+ popw %ax
+ ret
/*
* send_ansi_csi_2num
*
@@ -1266,16 +1213,16 @@ send_ansi_csi: /* transmit ESC [ */
send_ansi_csi_2num:
/* send ESC [ %dh ; %dl */
- pushw %ax
- call send_ansi_csi /* esc [ */
- movb %dh, %al
- call send_number
- movb $0x3b, %al /* semicolon */
- call send_byte
- movb %dl, %al
- call send_number
- popw %ax
- ret
+ pushw %ax
+ call send_ansi_csi /* esc [ */
+ movb %dh, %al
+ call send_number
+ movb $0x3b, %al /* semicolon */
+ call send_byte
+ movb %dl, %al
+ call send_number
+ popw %ax
+ ret
/*
* send_ansi_cursor_pos
@@ -1293,15 +1240,15 @@ send_ansi_csi_2num:
*/
send_ansi_cursor_pos:
- pushw %ax
- pushw %dx
- addw $0x0101, %dx /* dh += 1, dl += 1 */
- call send_ansi_csi_2num /* send esc [ %dh+1;%dl+1 */
- movb $0x48, %al /* H */
- call send_byte
- popw %dx
- popw %ax
- ret
+ pushw %ax
+ pushw %dx
+ addw $0x0101, %dx /* dh += 1, dl += 1 */
+ call send_ansi_csi_2num /* send esc [ %dh+1;%dl+1 */
+ movb $0x48, %al /* H */
+ call send_byte
+ popw %dx
+ popw %ax
+ ret
/*
* send_attribute
@@ -1315,56 +1262,56 @@ send_ansi_cursor_pos:
*/
send_attribute:
- andb $0x7f, %bl /* ansi has no bright bg */
- pushw %ds
- pushw %es
- pushw %ax
- pushw %bx
- pushw %dx
- pushw $BDA_SEG
- popw %es /* es = 0x40 */
- pushw %cs
- popw %ds /* ds = cs */
- cmpb %es:BDA_COLOR_VAL, %bl
- jz send_attribute_tail
- cmpb $0x07, %bl /* is it white on black? */
- jnz send_attribute_color
- /* for white on black, send esc [ m */
- call send_ansi_csi
- jmp send_attribute_m /* send the m, return */
+ andb $0x7f, %bl /* ansi has no bright bg */
+ pushw %ds
+ pushw %es
+ pushw %ax
+ pushw %bx
+ pushw %dx
+ pushw $BDA_SEG
+ popw %es /* es = 0x40 */
+ pushw %cs
+ popw %ds /* ds = cs */
+ cmpb %es:BDA_COLOR_VAL, %bl
+ jz send_attribute_tail
+ cmpb $0x07, %bl /* is it white on black? */
+ jnz send_attribute_color
+ /* for white on black, send esc [ m */
+ call send_ansi_csi
+ jmp send_attribute_m /* send the m, return */
send_attribute_color:
- movb %bl, %ah /* ah = attribute */
- movw $colortable, %bx
- movb %ah, %al
- andb $7, %al /* al = fg attr */
- xlatb /* al = fg ansi num */
- movb %al, %dl /* dl = fg ansi num */
- movb %ah, %al
- shrb $4, %al /* al = bg attr */
- xlatb /* al = bg ansi num */
- movb %al, %dh /* dh = bg ansi num */
- addw $0x281e, %dx /* 3x=setfg, 4x=setbg */
- call send_ansi_csi_2num
- movb $0x3b, %al /* semicolon */
- call send_byte
- shlb $4, %ah /* bright text? */
- sets %al /* if bit 7, al = 1 */
- js send_attribute_intensity
- movb $22, %al /* 22 = normal intensity */
+ movb %bl, %ah /* ah = attribute */
+ movw $colortable, %bx
+ movb %ah, %al
+ andb $7, %al /* al = fg attr */
+ xlatb /* al = fg ansi num */
+ movb %al, %dl /* dl = fg ansi num */
+ movb %ah, %al
+ shrb $4, %al /* al = bg attr */
+ xlatb /* al = bg ansi num */
+ movb %al, %dh /* dh = bg ansi num */
+ addw $0x281e, %dx /* 3x=setfg, 4x=setbg */
+ call send_ansi_csi_2num
+ movb $0x3b, %al /* semicolon */
+ call send_byte
+ shlb $4, %ah /* bright text? */
+ sets %al /* if bit 7, al = 1 */
+ js send_attribute_intensity
+ movb $22, %al /* 22 = normal intensity */
send_attribute_intensity:
- call send_number /* either 22 or 1 */
+ call send_number /* either 22 or 1 */
send_attribute_m:
- movb $0x6d, %al /* m */
- call send_byte
+ movb $0x6d, %al /* m */
+ call send_byte
send_attribute_tail:
- popw %dx
- popw %bx
- /* mark attribute in %bl the current one */
- movb %bl, %es:BDA_COLOR_VAL
- popw %ax
- popw %es
- popw %ds
- ret
+ popw %dx
+ popw %bx
+ /* mark attribute in %bl the current one */
+ movb %bl, %es:BDA_COLOR_VAL
+ popw %ax
+ popw %es
+ popw %ds
+ ret
/*
* serial_get_input
@@ -1378,30 +1325,31 @@ send_attribute_tail:
*/
serial_get_input:
- pushf
- cli /* be paranoid about int 9h happening during update */
- pushaw
- pushw %ds
- /* next char input buffer is at 0x40:0x1c */
- pushw $BDA_SEG
- popw %ds /* es = 0x40 */
- call get_byte /* next scancode/byte in %ax */
- cmpb $0x1b, %al /* look for escape */
- jnz serial_gotkey /* not escape, don't look for more bytes */
- call get_multibyte /* look for any chars after escape */
+ pushf
+ /* be paranoid about int 9h happening during update */
+ cli
+ pushaw
+ pushw %ds
+ /* next char input buffer is at 0x40:0x1c */
+ pushw $BDA_SEG
+ popw %ds /* es = 0x40 */
+ call get_byte /* next scancode/byte in %ax */
+ cmpb $0x1b, %al /* look for escape */
+ jnz serial_gotkey /* not escape, don't look for more bytes */
+ call get_multibyte /* look for any chars after escape */
serial_gotkey:
- movw KBD_TAIL, %bx /* bx = keyboard tail pointer */
- movw %ax, (%bx) /* store key in buffer */
- addw $2, %bx /* point to next location */
- cmpw $KBD_BUF_END, %bx /* did the buffer wrap? */
- jb kbd_buf_no_wrap
- movw $KBD_BUF_START, %bx
+ movw KBD_TAIL, %bx /* bx = keyboard tail pointer */
+ movw %ax, (%bx) /* store key in buffer */
+ addw $2, %bx /* point to next location */
+ cmpw $KBD_BUF_END, %bx /* did the buffer wrap? */
+ jb kbd_buf_no_wrap
+ movw $KBD_BUF_START, %bx
kbd_buf_no_wrap:
- movw %bx, KBD_TAIL /* update tail pointer to show key */
- popw %ds
- popaw
- popf
- ret
+ movw %bx, KBD_TAIL /* update tail pointer to show key */
+ popw %ds
+ popaw
+ popf
+ ret
/*
* irq3_isr
@@ -1422,25 +1370,25 @@ kbd_buf_no_wrap:
irq3_isr:
#if 0
- pushw %ax
- pushw %dx
- /* placeholder, this shouldn't ever happen */
- /* no interrupts are configured outside COM1 */
- call get_serial_lsr /* get serial lsr in %al */
- jz chain_irq3 /* no port present... */
- testb $1, %al /* check bit 0 of LSR for data available */
- jz chain_irq3 /* no input waiting */
- call serial_get_input /* get input and stuff kbd buffer */
- movb $0x20, %al
- outb %al, $0x20 /* send non-specific EOI */
- popw %dx
- popw %ax
- iret
+ pushw %ax
+ pushw %dx
+ /* placeholder, this shouldn't ever happen */
+ /* no interrupts are configured outside COM1 */
+ call get_serial_lsr /* get serial lsr in %al */
+ jz chain_irq3 /* no port present... */
+ testb $1, %al /* bit 0 of LSR = 1 = data available */
+ jz chain_irq3 /* no input waiting */
+ call serial_get_input /* get input and stuff kbd buffer */
+ movb $0x20, %al
+ outb %al, $0x20 /* send non-specific EOI */
+ popw %dx
+ popw %ax
+ iret
chain_irq3:
- popw %dx
- popw %ax
+ popw %dx
+ popw %ax
#endif
- jmp do_old_irq3
+ jmp do_old_irq3
/*
* irq4_isr
@@ -1461,23 +1409,23 @@ chain_irq3:
irq4_isr:
#if 0
- pushw %ax
- pushw %dx
- call get_serial_lsr /* get serial lsr in %al */
- jz chain_irq4 /* no port present... */
- testb $1, %al /* check bit 0 of LSR for data available */
- jz chain_irq4 /* no input waiting */
- call serial_get_input /* get input and stuff kbd buffer */
- movb $0x20, %al
- outb %al, $0x20 /* send non-specific EOI */
- popw %dx
- popw %ax
- iret
+ pushw %ax
+ pushw %dx
+ call get_serial_lsr /* get serial lsr in %al */
+ jz chain_irq4 /* no port present... */
+ testb $1, %al /* bit 0 of LSR = 1 = data available */
+ jz chain_irq4 /* no input waiting */
+ call serial_get_input /* get input and stuff kbd buffer */
+ movb $0x20, %al
+ outb %al, $0x20 /* send non-specific EOI */
+ popw %dx
+ popw %ax
+ iret
chain_irq4:
- popw %dx
- popw %ax
+ popw %dx
+ popw %ax
#endif
- jmp do_old_irq4
+ jmp do_old_irq4
/*
* int14h_isr
@@ -1486,51 +1434,51 @@ chain_irq4:
*
*/
int14h_isr:
- pushaw
- movw %sp, %bp
- addw $16, %bp /* bp points to return address */
- orb %ah, %ah /* fn 0x00, initialize port */
- jz int14h_init_port
- cmpb $0x04, %ah /* fn 0x04, extended intialize */
- jnz chain_isr14h
+ pushaw
+ movw %sp, %bp
+ addw $16, %bp /* bp points to return address */
+ orb %ah, %ah /* fn 0x00, initialize port */
+ jz int14h_init_port
+ cmpb $0x04, %ah /* fn 0x04, extended intialize */
+ jnz chain_isr14h
int14h_init_port:
- /* check for init port = current port */
- pushw %ds
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movw %dx, %bx /* bx = port number */
- shlw $1, %bx /* bx = port number * 2 */
- andw $7, %bx /* bx = offset of serial io address in bda */
- movw (%bx), %cx /* cx = io address of port to init */
- popw %ds /* restore original ds */
- cmpw %cx, %cs:serial_port_base_address
- jnz chain_isr14h /* if different, don't get in the way */
- /* init port == current port */
- pushw %ds
- /* LILO 22.6 HACK STARTS HERE */
- movw (%bp), %bx /* return address for int 14h call */
- movw 2(%bp), %ds /* return segment for int 14h call */
- cmpl $0x4f4c494c, 0x06 /* does segment have lilo signature? */
- jnz int14h_init_tail /* not lilo, bail on hack */
- cmpw $0x0616, 0x0a /* does version match lilo 22.6? */
- jnz int14h_init_tail /* not known lilo release, bail on hack */
- movb $0, 0x12 /* set lilo com port = 0 */
- movl $0x90c3585a, (%bx) /* return code= pop dx;pop ax;ret;nop */
- /* now lilo 22.6's own serial out is permanently disabled */
- /* this prevents double-character output from int10h + serial */
- /* this also prevents lilo from stealing serial input chars */
- /* END LILO 22.6 HACK */
+ /* check for init port = current port */
+ pushw %ds
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movw %dx, %bx /* bx = port number */
+ shlw $1, %bx /* bx = port number * 2 */
+ andw $7, %bx /* bx = bda offset of serial io addr */
+ movw (%bx), %cx /* cx = io address of port to init */
+ popw %ds /* restore original ds */
+ cmpw %cx, %cs:serial_port_base_address
+ jnz chain_isr14h /* if different, don't get in the way */
+ /* init port == current port */
+ pushw %ds
+ /* LILO 22.6 HACK STARTS HERE */
+ movw (%bp), %bx /* return address for int 14h call */
+ movw 2(%bp), %ds /* return segment for int 14h call */
+ cmpl $0x4f4c494c, 0x06 /* does segment have lilo signature? */
+ jnz int14h_init_tail /* not lilo, bail on hack */
+ cmpw $0x0616, 0x0a /* does version match lilo 22.6? */
+ jnz int14h_init_tail /* unknown lilo release, bail on hack */
+ movb $0, 0x12 /* set lilo com port = 0 */
+ movl $0x90c3585a, (%bx) /* return code= pop dx;pop ax;ret;nop */
+ /* now lilo 22.6's own serial out is permanently disabled */
+ /* this prevents double-character output from int10h + serial */
+ /* this also prevents lilo from stealing serial input chars */
+ /* END LILO 22.6 HACK */
int14h_init_tail:
- popw %ds
- popaw
- pushw %dx /* get_serial_lsr trashes %dx */
- call get_serial_lsr /* return serial status in %al */
- xorb %ah, %ah /* return serial status in %ax */
- popw %dx /* restore %dx */
- iret
+ popw %ds
+ popaw
+ pushw %dx /* get_serial_lsr trashes %dx */
+ call get_serial_lsr /* return serial status in %al */
+ xorb %ah, %ah /* return serial status in %ax */
+ popw %dx /* restore %dx */
+ iret
chain_isr14h:
- popaw
- jmp do_old_int14h
+ popaw
+ jmp do_old_int14h
/*
* int16h_isr
@@ -1550,22 +1498,22 @@ chain_isr14h:
*/
int16h_isr:
- pushw %ax
- pushw %dx
- /* each time int 16h is invoked, fake an int 9h */
- /* except read the serial input buffer */
- /* then chain to the original int 16h for processing */
- call get_serial_lsr
- jz chain_isr16h /* no port present... */
- testb $1, %al /* check bit 0 of LSR for data available */
- jz chain_isr16h /* no input waiting */
- call serial_get_input /* get input and stuff kbd buffer */
- /* for now, leave remaining chars pending in serial fifo */
- /* int 16h callers only get one char at a time anyway */
+ pushw %ax
+ pushw %dx
+ /* each time int 16h is invoked, fake an int 9h */
+ /* except read the serial input buffer */
+ /* then chain to the original int 16h for processing */
+ call get_serial_lsr
+ jz chain_isr16h /* no port present... */
+ testb $1, %al /* bit 0 of LSR = 1 = data available */
+ jz chain_isr16h /* no input waiting */
+ call serial_get_input /* get input and stuff kbd buffer */
+ /* for now, leave remaining chars pending in serial fifo */
+ /* int 16h callers only get one char at a time anyway */
chain_isr16h:
- popw %dx
- popw %ax
- jmp do_old_int16h
+ popw %dx
+ popw %ax
+ jmp do_old_int16h
/*
* update serial_cursor
@@ -1578,66 +1526,66 @@ chain_isr16h:
* bda updated with new position for serial console cursor
*/
update_serial_cursor:
- pushw %ax
- pushw %bx
- pushw %dx
- pushw %ds
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- call get_current_cursor /* dh = row, dl = col */
- movw BDA_SERIAL_POS, %bx /* bh = row, bl = col */
- subb %dl, %bl /* -col update */
- negb %bl /* col update */
- subb %dh, %bh /* -row update */
- negb %bh /* row update */
- /* handle a few special movement cases */
- /* cr, lf, bs, bs+bs, space, else send full ansi position */
- orb %dl, %dl /* column zero? */
- jnz update_serial_cursor_lf
- movb $0x0d, %al /* CR */
- call send_byte
- xorb %bl, %bl /* mark no diff in col */
+ pushw %ax
+ pushw %bx
+ pushw %dx
+ pushw %ds
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ call get_current_cursor /* dh = row, dl = col */
+ movw BDA_SERIAL_POS, %bx /* bh = row, bl = col */
+ subb %dl, %bl /* -col update */
+ negb %bl /* col update */
+ subb %dh, %bh /* -row update */
+ negb %bh /* row update */
+ /* handle a few special movement cases */
+ /* cr, lf, bs, bs+bs, space, else send full ansi position */
+ orb %dl, %dl /* column zero? */
+ jnz update_serial_cursor_lf
+ movb $0x0d, %al /* CR */
+ call send_byte
+ xorb %bl, %bl /* mark no diff in col */
update_serial_cursor_lf:
- cmpb $1, %bh /* +1 row? */
- jnz update_serial_cursor_bs
- movb $0x0a, %al /* LF */
- call send_byte
- xorb %bh, %bh /* mark no diff in row */
+ cmpb $1, %bh /* +1 row? */
+ jnz update_serial_cursor_bs
+ movb $0x0a, %al /* LF */
+ call send_byte
+ xorb %bh, %bh /* mark no diff in row */
update_serial_cursor_bs:
- cmpb $-1, %bl /* one char back */
- jz update_serial_cursor_one_bs
- cmpb $-2, %bl /* two chars back */
- jnz update_serial_cursor_space /* check for space */
- movb $0x08, %al /* BS */
- call send_byte
+ cmpb $-1, %bl /* one char back */
+ jz update_serial_cursor_one_bs
+ cmpb $-2, %bl /* two chars back */
+ jnz update_serial_cursor_space /* check for space */
+ movb $0x08, %al /* BS */
+ call send_byte
update_serial_cursor_one_bs:
- movb $0x08, %al /* BS */
- call send_byte
- xorb %bl, %bl /* mark no diff in col */
+ movb $0x08, %al /* BS */
+ call send_byte
+ xorb %bl, %bl /* mark no diff in col */
update_serial_cursor_space:
- cmpb $1, %bl /* one char forward */
- jnz update_serial_cursor_up
- movb $0x20, %al /* space */
- call send_byte
- xorb %bl, %bl /* mark no diff in col */
+ cmpb $1, %bl /* one char forward */
+ jnz update_serial_cursor_up
+ movb $0x20, %al /* space */
+ call send_byte
+ xorb %bl, %bl /* mark no diff in col */
update_serial_cursor_up:
- cmpb $-1, %bh /* -1 row? */
- jnz update_serial_cursor_full /* do full ansi pos update */
- call send_ansi_csi /* send ESC [ A (cursor up) */
- movb $0x41, %al /* A */
- call send_byte
- xorb %bh, %bh /* mark no diff in row */
+ cmpb $-1, %bh /* -1 row? */
+ jnz update_serial_cursor_full /* do full ansi pos update */
+ call send_ansi_csi /* send ESC [ A (cursor up) */
+ movb $0x41, %al /* A */
+ call send_byte
+ xorb %bh, %bh /* mark no diff in row */
update_serial_cursor_full:
- orw %bx, %bx /* diff = 0? */
- jz update_serial_cursor_done
- call send_ansi_cursor_pos /* set cursor pos from dh,dl */
+ orw %bx, %bx /* diff = 0? */
+ jz update_serial_cursor_done
+ call send_ansi_cursor_pos /* set cursor pos from dh,dl */
update_serial_cursor_done:
- movw %dx, BDA_SERIAL_POS
- popw %ds
- popw %dx
- popw %bx
- popw %ax
- ret
+ movw %dx, BDA_SERIAL_POS
+ popw %ds
+ popw %dx
+ popw %bx
+ popw %ax
+ ret
/*
* write_teletype
@@ -1653,12 +1601,12 @@ update_serial_cursor_done:
*/
write_teletype:
- pushw %bx
- movb $0x07, %bl /* black bg, white fg */
- call send_attribute
- popw %bx
- call send_char_tty
- ret
+ pushw %bx
+ movb $0x07, %bl /* black bg, white fg */
+ call send_attribute
+ popw %bx
+ call send_char_tty
+ ret
/*
* write_attr_char
@@ -1677,8 +1625,8 @@ write_teletype:
*/
write_attr_char:
- call send_attribute /* send attribute in %bl */
- jmp write_char_common
+ call send_attribute /* send attribute in %bl */
+ jmp write_char_common
/*
* write_char
@@ -1696,22 +1644,22 @@ write_attr_char:
*/
write_char:
- pushw %bx
- movb $0x07, %bl /* black bg, white fg */
- call send_attribute
- popw %bx
+ pushw %bx
+ movb $0x07, %bl /* black bg, white fg */
+ call send_attribute
+ popw %bx
write_char_common:
- call get_current_cursor
- call send_char
- /* make cx=0 and cx=1 only output one char */
- cmpw $1, %cx
- jbe write_char_tail
- decw %cx
- jmp write_char
+ call get_current_cursor
+ call send_char
+ /* make cx=0 and cx=1 only output one char */
+ cmpw $1, %cx
+ jbe write_char_tail
+ decw %cx
+ jmp write_char
write_char_tail:
- /* put cursor back where it was on entry */
- call set_current_cursor
- ret
+ /* put cursor back where it was on entry */
+ call set_current_cursor
+ ret
/*
* write_string
@@ -1726,7 +1674,7 @@ write_char_tail:
* bh = display page number
* bl = character attribute for all chars (if al = 0 or 1)
* cx = characters in string (attributes don't count)
- * dh = cursor row start
+ * dh = cursor row start
* dl = cursor column start
* es:bp = pointer to source text string in memory
*
@@ -1734,31 +1682,31 @@ write_char_tail:
* caller will restore all registers
*/
write_string:
- call set_cursor_position
- pushw %ds
- pushw %es
- pushw %es
- popw %ds /* ds = es */
- movw %bp, %si /* si = bp */
- testb $2, %al
- jnz write_attr_string
- call send_attribute /* send attribute in %bl */
- test %cx, %cx
- jz write_string_empty
- call send_string /* plaintext out */
+ call set_cursor_position
+ pushw %ds
+ pushw %es
+ pushw %es
+ popw %ds /* ds = es */
+ movw %bp, %si /* si = bp */
+ testb $2, %al
+ jnz write_attr_string
+ call send_attribute /* send attribute in %bl */
+ test %cx, %cx
+ jz write_string_empty
+ call send_string /* plaintext out */
write_string_empty:
- jmp write_string_update_cursor
+ jmp write_string_update_cursor
write_attr_string:
- call send_attr_string /* text+attrib out */
+ call send_attr_string /* text+attrib out */
write_string_update_cursor:
- testb $1, %al /* cursor update? */
- jnz write_string_tail /* yes? already happened */
- /* restore entry cursor position if no update */
- call set_cursor_position
+ testb $1, %al /* cursor update? */
+ jnz write_string_tail /* yes? already happened */
+ /* restore entry cursor position if no update */
+ call set_cursor_position
write_string_tail:
- popw %es
- popw %ds
- ret
+ popw %es
+ popw %ds
+ ret
/*
* set_cursor_position
@@ -1779,19 +1727,19 @@ write_string_tail:
*/
set_cursor_position:
- pushw %ax
- pushw %ds
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movzbw %bh, %ax /* ax = page number */
- andb $0x07, %al /* prevent invalid page number */
- shlb $1, %al /* calculate word offset */
- addb $BDA_CURSOR_BUF, %al /* ax = cursor save offset */
- movw %ax, %bx /* bx = cursor save offset */
- movw %dx, (%bx) /* save new cursor value */
- popw %ds
- popw %ax
- ret
+ pushw %ax
+ pushw %ds
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movzbw %bh, %ax /* ax = page number */
+ andb $0x07, %al /* prevent invalid page number */
+ shlb $1, %al /* calculate word offset */
+ addb $BDA_CURSOR_BUF, %al /* ax = cursor save offset */
+ movw %ax, %bx /* bx = cursor save offset */
+ movw %dx, (%bx) /* save new cursor value */
+ popw %ds
+ popw %ax
+ ret
/*
* set_current_cursor
@@ -1803,15 +1751,15 @@ set_cursor_position:
*/
set_current_cursor:
- pushw %ds
- pushw %bx
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movb BDA_ACTIVE_PAGE, %bh
- call set_cursor_position
- popw %bx
- popw %ds
- ret
+ pushw %ds
+ pushw %bx
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movb BDA_ACTIVE_PAGE, %bh
+ call set_cursor_position
+ popw %bx
+ popw %ds
+ ret
/*
* get_cursor_common
@@ -1821,25 +1769,25 @@ set_current_cursor:
* returns:
* dh = cursor row
* dl = cursor column
- * ch = cursor start scanline
- * cl = cursor end scanline
+ * ch = cursor start scanline
+ * cl = cursor end scanline
*
* all registers except %dx, %cx preserved
*/
get_cursor_common:
- pushw %bx
- pushw %ds
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movzbw %bh, %bx /* dx = current page */
- andb $7, %bl
- shlb $1, %bl
- addb $BDA_CURSOR_BUF, %bl
- movw (%bx), %dx /* get cursor pos */
- movw BDA_CURSOR_SCAN, %cx
- popw %ds
- popw %bx
- ret
+ pushw %bx
+ pushw %ds
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movzbw %bh, %bx /* dx = current page */
+ andb $7, %bl
+ shlb $1, %bl
+ addb $BDA_CURSOR_BUF, %bl
+ movw (%bx), %dx /* get cursor pos */
+ movw BDA_CURSOR_SCAN, %cx
+ popw %ds
+ popw %bx
+ ret
/*
* get_current_cursor
@@ -1854,17 +1802,17 @@ get_cursor_common:
*/
get_current_cursor:
- pushw %ds
- pushw %bx
- pushw %cx
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movb BDA_ACTIVE_PAGE, %bh
- call get_cursor_common
- popw %cx
- popw %bx
- popw %ds
- ret
+ pushw %ds
+ pushw %bx
+ pushw %cx
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movb BDA_ACTIVE_PAGE, %bh
+ call get_cursor_common
+ popw %cx
+ popw %bx
+ popw %ds
+ ret
/*
* get_cursor_position
@@ -1885,13 +1833,13 @@ get_current_cursor:
*/
get_cursor_position:
- call bail_if_vga_attached /* does not return if vga attached */
- popw %ax /* not chaining, pop fake return address */
- popw %dx /* not chaining, pop saved cursor position */
- popaw /* not chaining to old int 10h, pop saved state */
- call get_cursor_common
- xorw %ax, %ax
- iret
+ call bail_if_vga_attached /* does not return if vga attached */
+ popw %ax /* not chaining, pop fake return address */
+ popw %dx /* not chaining, pop saved cursor position */
+ popaw /* not chaining to old int 10h, pop saved state */
+ call get_cursor_common
+ xorw %ax, %ax
+ iret
/*
* return_current_video_state
@@ -1909,18 +1857,18 @@ get_cursor_position:
*/
read_current_video_state:
- call bail_if_vga_attached /* does not return if vga attached */
- popw %ax /* not chaining, pop fake return address */
- popw %dx /* not chaining, pop saved cursor position */
- popaw /* not chaining to old int 10h, pop saved state */
- pushw %ds
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movb BDA_COLS, %ah
- movb BDA_MODE_NUM, %al
- movb BDA_ACTIVE_PAGE, %bh
- popw %ds
- iret
+ call bail_if_vga_attached /* does not return if vga attached */
+ popw %ax /* not chaining, pop fake return address */
+ popw %dx /* not chaining, pop saved cursor position */
+ popaw /* not chaining to old int 10h, pop saved state */
+ pushw %ds
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movb BDA_COLS, %ah
+ movb BDA_MODE_NUM, %al
+ movb BDA_ACTIVE_PAGE, %bh
+ popw %ds
+ iret
/*
* read_attr_char
@@ -1937,17 +1885,17 @@ read_current_video_state:
*/
read_attr_char:
- call bail_if_vga_attached /* does not return if vga attached */
- popw %ax /* not chaining, pop fake return address */
- popw %dx /* not chaining, pop saved cursor position */
- popaw /* not chaining to old int 10h, pop saved state */
- pushw %ds
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movb BDA_COLOR_VAL, %ah /* return last color value */
- call sgabioslog_get_char
- popw %ds
- iret
+ call bail_if_vga_attached /* does not return if vga attached */
+ popw %ax /* not chaining, pop fake return address */
+ popw %dx /* not chaining, pop saved cursor position */
+ popaw /* not chaining to old int 10h, pop saved state */
+ pushw %ds
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movb BDA_COLOR_VAL, %ah /* return last color value */
+ call sgabioslog_get_char
+ popw %ds
+ iret
/*
* set_video_mode
@@ -1963,20 +1911,20 @@ read_attr_char:
*/
set_video_mode:
- testb $0x80, %al /* preserve screen flag? */
- jnz set_video_mode_tail
- call send_ansi_csi
- movb $0x32, %al /* 2 */
- call send_byte
- movb $0x4a, %al /* J */
- call send_byte
+ testb $0x80, %al /* preserve screen flag? */
+ jnz set_video_mode_tail
+ call send_ansi_csi
+ movb $0x32, %al /* 2 */
+ call send_byte
+ movb $0x4a, %al /* J */
+ call send_byte
set_video_mode_tail:
- movb $0x07, %bl /* white on black text */
- call send_attribute /* send attribute in %bl */
- /* set cursor position to 0,0 */
- xorb %bh, %bh /* page 0 */
- xorw %dx, %dx
- jmp set_cursor_position
+ movb $0x07, %bl /* white on black text */
+ call send_attribute /* send attribute in %bl */
+ /* set cursor position to 0,0 */
+ xorb %bh, %bh /* page 0 */
+ xorw %dx, %dx
+ jmp set_cursor_position
/*
* scroll_page_up
@@ -1995,21 +1943,21 @@ set_video_mode_tail:
*/
scroll_page_up:
- pushw %si
- pushw %dx
- call get_current_cursor /* save current cursor */
- movw %dx, %si /* si = vga cursor pos */
- popw %dx
- cmpb $0, %al /* al = 0 = clear window */
- jz scroll_common_clear
- pushw %ax
- call send_ansi_csi /* CSI [ %al S */
- call send_number
- movb $0x53, %al /* S */
- call send_byte
- popw %dx
- popw %si
- ret
+ pushw %si
+ pushw %dx
+ call get_current_cursor /* save current cursor */
+ movw %dx, %si /* si = vga cursor pos */
+ popw %dx
+ cmpb $0, %al /* al = 0 = clear window */
+ jz scroll_common_clear
+ pushw %ax
+ call send_ansi_csi /* CSI [ %al S */
+ call send_number
+ movb $0x53, %al /* S */
+ call send_byte
+ popw %dx
+ popw %si
+ ret
/*
* scroll_common_clear
@@ -2027,65 +1975,65 @@ scroll_page_up:
* dl = right-most column (lower right corner) of window
*/
scroll_common_clear:
- pushw %ax
- xchgb %bl, %bh /* bl = attribute, bh = old bl */
- call send_attribute /* send attribute in %bl */
- xchgb %bl, %bh /* restore bx */
- pushw %ds
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- /* check to see if region is full screen, and attribute default */
- orw %cx, %cx /* is top left 0,0? */
- jnz scroll_common_window /* no, handle window */
- cmpb $0x07, %bh /* is attribute white on black? */
- jnz scroll_common_window /* no, must write spaces */
+ pushw %ax
+ xchgb %bl, %bh /* bl = attribute, bh = old bl */
+ call send_attribute /* send attribute in %bl */
+ xchgb %bl, %bh /* restore bx */
+ pushw %ds
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ /* check to see if region is full screen, and attribute default */
+ orw %cx, %cx /* is top left 0,0? */
+ jnz scroll_common_window /* no, handle window */
+ cmpb $0x07, %bh /* is attribute white on black? */
+ jnz scroll_common_window /* no, must write spaces */
#ifdef LILO_CLEAR_WORKAROUND_NOT_REQUIRED
- cmpb %cs:term_cols, %dl /* is right less than cols ? */
- jc scroll_common_window /* if so, handle window */
- cmpb %cs:term_rows, %dh /* is bottom less than rows ? */
- jc scroll_common_window /* if so, handle window */
+ cmpb %cs:term_cols, %dl /* is right less than cols ? */
+ jc scroll_common_window /* if so, handle window */
+ cmpb %cs:term_rows, %dh /* is bottom less than rows ? */
+ jc scroll_common_window /* if so, handle window */
#endif
- /* safe to send standard clear screen sequence */
- call send_ansi_csi /* send ESC [ */
- movb $0x32, %al /* 2 */
- call send_byte
- movb $0x4a, %al /* J */
- call send_byte
- jmp scroll_common_tail
+ /* safe to send standard clear screen sequence */
+ call send_ansi_csi /* send ESC [ */
+ movb $0x32, %al /* 2 */
+ call send_byte
+ movb $0x4a, %al /* J */
+ call send_byte
+ jmp scroll_common_tail
scroll_common_window:
- pushw %dx
- movw %cx, %dx /* dx = upper right */
- call set_current_cursor
- popw %dx
- pushw %cx
- /* setup cx with count of chars to clear per row */
- xorb %ch, %ch
- negb %cl
- addb %dl, %cl /* cl = dl - cl */
- incb %cl /* start = end col = clear 1 col */
- cmpb %cs:term_cols, %cl /* is count < cols? */
- jc scroll_common_row_ok /* if so then skip limit */
- movb %cs:term_cols, %cl /* limit count to cols */
+ pushw %dx
+ movw %cx, %dx /* dx = upper right */
+ call set_current_cursor
+ popw %dx
+ pushw %cx
+ /* setup cx with count of chars to clear per row */
+ xorb %ch, %ch
+ negb %cl
+ addb %dl, %cl /* cl = dl - cl */
+ incb %cl /* start = end col = clear 1 col */
+ cmpb %cs:term_cols, %cl /* is count < cols? */
+ jc scroll_common_row_ok /* if so then skip limit */
+ movb %cs:term_cols, %cl /* limit count to cols */
scroll_common_row_ok:
- jz scroll_common_row_done /* count == 0 ? */
- movb $0x20, %al /* space */
+ jz scroll_common_row_done /* count == 0 ? */
+ movb $0x20, %al /* space */
scroll_common_space_loop:
- call send_char
- loop scroll_common_space_loop /* send cx spaces */
+ call send_char
+ loop scroll_common_space_loop /* send cx spaces */
scroll_common_row_done:
- popw %cx
- incb %ch /* top left now next row */
- cmpb %dh, %ch
- jbe scroll_common_window /* do next row */
+ popw %cx
+ incb %ch /* top left now next row */
+ cmpb %dh, %ch
+ jbe scroll_common_window /* do next row */
scroll_common_tail:
- popw %ds
- popw %ax
- pushw %dx
- movw %si, %dx /* dx = saved vga cursor pos */
- call set_current_cursor /* restore saved cursor */
- popw %dx
- popw %si
- ret
+ popw %ds
+ popw %ax
+ pushw %dx
+ movw %si, %dx /* dx = saved vga cursor pos */
+ call set_current_cursor /* restore saved cursor */
+ popw %dx
+ popw %si
+ ret
/*
* scroll_page_down
@@ -2107,21 +2055,21 @@ scroll_common_tail:
*/
scroll_page_down:
- pushw %si
- pushw %dx
- call get_current_cursor /* save current cursor */
- movw %dx, %si /* si = vga cursor pos */
- popw %dx
- cmpb $0, %al /* al = 0 = clear window */
- jz scroll_common_clear
- pushw %ax
- call send_ansi_csi /* CSI [ %al T */
- call send_number
- movb $0x54, %al /* T */
- call send_byte
- popw %dx
- popw %si
- ret
+ pushw %si
+ pushw %dx
+ call get_current_cursor /* save current cursor */
+ movw %dx, %si /* si = vga cursor pos */
+ popw %dx
+ cmpb $0, %al /* al = 0 = clear window */
+ jz scroll_common_clear
+ pushw %ax
+ call send_ansi_csi /* CSI [ %al T */
+ call send_number
+ movb $0x54, %al /* T */
+ call send_byte
+ popw %dx
+ popw %si
+ ret
/*
* bail_if_vga_attached
@@ -2136,11 +2084,11 @@ scroll_page_down:
*/
bail_if_vga_attached:
- cmpw $0xc000, %cs:old_int10h_seg /* vga attached? */
- jnz bail_tail /* if not, don't modify stack */
- addw $2, %sp /* else drop first return address */
+ cmpw $0xc000, %cs:old_int10h_seg /* vga attached? */
+ jnz bail_tail /* if not, don't modify stack */
+ addw $2, %sp /* else drop first return address */
bail_tail:
- ret /* return to caller or chain_isr_10h */
+ ret /* return to caller or chain_isr_10h */
/*
* int10h_isr
@@ -2178,67 +2126,67 @@ bail_tail:
*/
int10h_isr:
- pushaw
- call get_current_cursor
- pushw %dx /* save current cursor */
- pushw %bp /* need bp for indexing off stack */
- movw %sp, %bp /* bp = sp */
- movw 14(%bp), %dx /* restore dx value from earlier pushaw */
- popw %bp /* restore old bp */
- pushw $chain_isr10h /* force return to chain_isr10h */
- testb %ah, %ah
- jnz int10h_02
- jmp set_video_mode
+ pushaw
+ call get_current_cursor
+ pushw %dx /* save current cursor */
+ pushw %bp /* need bp for indexing off stack */
+ movw %sp, %bp /* bp = sp */
+ movw 14(%bp), %dx /* restore dx from earlier pushaw */
+ popw %bp /* restore old bp */
+ pushw $chain_isr10h /* force return to chain_isr10h */
+ testb %ah, %ah
+ jnz int10h_02
+ jmp set_video_mode
int10h_02:
- cmpb $0x02, %ah
- jnz int10h_03
- jmp set_cursor_position
+ cmpb $0x02, %ah
+ jnz int10h_03
+ jmp set_cursor_position
int10h_03:
- cmpb $0x03, %ah
- jnz int10h_06
- jmp get_cursor_position
+ cmpb $0x03, %ah
+ jnz int10h_06
+ jmp get_cursor_position
int10h_06:
- cmpb $0x06, %ah
- jnz int10h_07
- jmp scroll_page_up
+ cmpb $0x06, %ah
+ jnz int10h_07
+ jmp scroll_page_up
int10h_07:
- cmpb $0x07, %ah
- jnz int10h_08
- jmp scroll_page_down
+ cmpb $0x07, %ah
+ jnz int10h_08
+ jmp scroll_page_down
int10h_08:
- cmpb $0x08, %ah
- jnz int10h_09
- jmp read_attr_char
+ cmpb $0x08, %ah
+ jnz int10h_09
+ jmp read_attr_char
int10h_09:
- cmpb $0x09, %ah
- jnz int10h_0a
- jmp write_attr_char
+ cmpb $0x09, %ah
+ jnz int10h_0a
+ jmp write_attr_char
int10h_0a:
- cmpb $0x0a, %ah
- jnz int10h_0e
- jmp write_char
+ cmpb $0x0a, %ah
+ jnz int10h_0e
+ jmp write_char
int10h_0e:
- cmpb $0x0e, %ah
- jnz int10h_0f
- jmp write_teletype
+ cmpb $0x0e, %ah
+ jnz int10h_0f
+ jmp write_teletype
int10h_0f:
- cmpb $0x0f, %ah
- jnz int10h_13
- jmp read_current_video_state
+ cmpb $0x0f, %ah
+ jnz int10h_13
+ jmp read_current_video_state
int10h_13:
- cmpb $0x13, %ah
- jnz int10h_default
- jmp write_string
+ cmpb $0x13, %ah
+ jnz int10h_default
+ jmp write_string
int10h_default:
- popw %ax /* pop chain_isr10h return address */
+ popw %ax /* pop chain_isr10h return address */
chain_isr10h:
- popw %dx /* pop saved cursor */
- cmpw $0xc000, %cs:old_int10h_seg /* vga attached? */
- jnz chain_post_cursor /* if not, don't restore the cursor */
- call set_current_cursor /* restore cursor if video card connected */
+ popw %dx /* pop saved cursor */
+ cmpw $0xc000, %cs:old_int10h_seg /* vga attached? */
+ jnz chain_post_cursor /* if not, don't restore the cursor */
+ call set_current_cursor /* restore cursor if vga attached */
chain_post_cursor:
- popaw
- jmp do_old_int10h
+ popaw
+ jmp do_old_int10h
/*
* pnp_sga_init
@@ -2278,8 +2226,8 @@ chain_post_cursor:
*/
pnp_sga_init:
- /* FIXME: this is *wrong* -- init only what bios says to init */
- movw $0xca, %ax /* 0xca = attached int 10h, 9h display, input */
+ /* FIXME: this is *wrong* -- init only what bios says to init */
+ movw $0xca, %ax /* 0xca = attached int 10h, 9h display, input */
/*
* sga_init
@@ -2290,197 +2238,197 @@ pnp_sga_init:
*/
sga_init:
- /* this is probably paranoid about register preservation */
- pushfw
- cli /* more paranoia */
- pushaw
- pushw %ds
- pushw %es
- pushw $0
- popw %es /* es = 0 */
- pushw %cs
- popw %ds /* ds = cs */
- /* get original ISR */
- movl %es:0x28, %eax /* eax = old irq 3/int 0bh */
- movl %eax, old_irq3 /* save away old irq 4/int 0bh */
- movl %es:0x2c, %eax /* eax = old irq 4/int 0ch */
- movl %eax, old_irq4 /* save away old irq 4/int 0ch */
- movl %es:0x40, %eax /* eax = old int 10h */
- movl %eax, old_int10h /* save away old int 10h */
- movl %es:0x50, %eax /* eax = old int 14h */
- movl %eax, old_int14h /* save away old int 14h */
- movl %es:0x58, %eax /* eax = old int 16h */
- movl %eax, old_int16h /* save away old int 16h */
- movw $irq3_isr, %es:0x28 /* new irq 3 offset */
- movw %cs, %es:0x2a /* write new irq 3 seg */
- movw $irq4_isr, %es:0x2c /* new irq 4 offset */
- movw %cs, %es:0x2e /* write new irq 4 seg */
- movw $int10h_isr, %es:0x40 /* new int 10h offset */
- movw %cs, %es:0x42 /* write new int10h seg */
- movw $int14h_isr, %es:0x50 /* new int 14h offset */
- movw %cs, %es:0x52 /* write new int14h seg */
- movw $int16h_isr, %es:0x58 /* new int 16h offset */
- movw %cs, %es:0x5a /* write new int16h seg */
- /* empty input buffer to prepare for terminal sizing */
- call init_serial_port
+ /* this is probably paranoid about register preservation */
+ pushfw
+ cli /* more paranoia */
+ pushaw
+ pushw %ds
+ pushw %es
+ pushw $0
+ popw %es /* es = 0 */
+ pushw %cs
+ popw %ds /* ds = cs */
+ /* get original ISR */
+ movl %es:0x28, %eax /* eax = old irq 3/int 0bh */
+ movl %eax, old_irq3 /* save away old irq 4/int 0bh */
+ movl %es:0x2c, %eax /* eax = old irq 4/int 0ch */
+ movl %eax, old_irq4 /* save away old irq 4/int 0ch */
+ movl %es:0x40, %eax /* eax = old int 10h */
+ movl %eax, old_int10h /* save away old int 10h */
+ movl %es:0x50, %eax /* eax = old int 14h */
+ movl %eax, old_int14h /* save away old int 14h */
+ movl %es:0x58, %eax /* eax = old int 16h */
+ movl %eax, old_int16h /* save away old int 16h */
+ movw $irq3_isr, %es:0x28 /* new irq 3 offset */
+ movw %cs, %es:0x2a /* write new irq 3 seg */
+ movw $irq4_isr, %es:0x2c /* new irq 4 offset */
+ movw %cs, %es:0x2e /* write new irq 4 seg */
+ movw $int10h_isr, %es:0x40 /* new int 10h offset */
+ movw %cs, %es:0x42 /* write new int10h seg */
+ movw $int14h_isr, %es:0x50 /* new int 14h offset */
+ movw %cs, %es:0x52 /* write new int14h seg */
+ movw $int16h_isr, %es:0x58 /* new int 16h offset */
+ movw %cs, %es:0x5a /* write new int16h seg */
+ /* empty input buffer to prepare for terminal sizing */
+ call init_serial_port
input_clear_loop:
- call get_byte
- jnz input_clear_loop
- movw $term_init_string, %si
- call send_asciz_out
- push $BDA_SEG
- push $BDA_SEG
- popw %ds /* ds = 0x40 */
- popw %es /* es = 0x40 */
- movw $BDA_CURSOR_BUF, %di
+ call get_byte
+ jnz input_clear_loop
+ movw $term_init_string, %si
+ call send_asciz_out
+ push $BDA_SEG
+ push $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ popw %es /* es = 0x40 */
+ movw $BDA_CURSOR_BUF, %di
input_timeout_loop:
- /* get input from terminal until timeout found */
- /* store input at 40:50 - 40:5e (cursor pos) */
- call poll_byte
- jz input_timeout
- stosb /* es:di */
- cmpw $0x5f, %di /* 14 characters max */
- jnz input_timeout_loop /* good for more data */
+ /* get input from terminal until timeout found */
+ /* store input at 40:50 - 40:5e (cursor pos) */
+ call poll_byte
+ jz input_timeout
+ stosb /* es:di */
+ cmpw $0x5f, %di /* 14 characters max */
+ jnz input_timeout_loop /* good for more data */
input_timeout:
- xorb %al, %al /* nul terminate input */
- stosb
- cmpw $0x58, %di /* less than 8 chars? */
- jc resize_end /* too small to have valid data */
- movw $BDA_CURSOR_BUF, %si /* point to start */
- lodsw /* ax = first 2 chars */
- cmpw $0x5b1b, %ax /* was it "ESC[" ? */
- jnz resize_end /* reply starts ESC[row;colR */
- xorb %bl, %bl /* bl = ascii->int conversion */
+ xorb %al, %al /* nul terminate input */
+ stosb
+ cmpw $0x58, %di /* less than 8 chars? */
+ jc resize_end /* too small to have valid data */
+ movw $BDA_CURSOR_BUF, %si /* point to start */
+ lodsw /* ax = first 2 chars */
+ cmpw $0x5b1b, %ax /* was it "ESC[" ? */
+ jnz resize_end /* reply starts ESC[row;colR */
+ xorb %bl, %bl /* bl = ascii->int conversion */
input_first_number:
- lodsb /* al = next char */
- cmpb $0x30, %al
- jc resize_end /* char < 0x30 invalid */
- cmpb $0x3a, %al /* is char < 0x3a */
- jnc input_semicolon
- andb $0x0f, %al /* al = 0 - 9 */
- movb %bl, %ah /* ah = last conversion */
- aad /* ax = (al + ah * 10) & 0xff */
- movb %al, %bl /* bl = row ascii->int conversion */
- jmp input_first_number
+ lodsb /* al = next char */
+ cmpb $0x30, %al
+ jc resize_end /* char < 0x30 invalid */
+ cmpb $0x3a, %al /* is char < 0x3a */
+ jnc input_semicolon
+ andb $0x0f, %al /* al = 0 - 9 */
+ movb %bl, %ah /* ah = last conversion */
+ aad /* ax = (al + ah * 10) & 0xff */
+ movb %al, %bl /* bl = row ascii->int conversion */
+ jmp input_first_number
input_semicolon:
- /* at this point bl should contain rows, al = ; */
- /* sanity check, bail if invalid */
- cmpb $0x3b, %al
- jnz resize_end /* invalid input found */
- cmpb $0x0a, %bl /* less than 10 rows? */
- jc suspect_loopback /* consider input invalid */
- xorb %bh, %bh /* bh = col ascii->int conversion */
+ /* at this point bl should contain rows, al = ; */
+ /* sanity check, bail if invalid */
+ cmpb $0x3b, %al
+ jnz resize_end /* invalid input found */
+ cmpb $0x0a, %bl /* less than 10 rows? */
+ jc suspect_loopback /* consider input invalid */
+ xorb %bh, %bh /* bh = col ascii->int conversion */
input_second_number:
- lodsb /* al = next char */
- cmpb $0x30, %al
- jc resize_end /* char < 0x30 invalid */
- cmpb $0x3a, %al /* is char < 0x3a */
- jnc input_final_r
- andb $0x0f, %al /* al = 0 - 9 */
- movb %bh, %ah /* ah = last conversion */
- aad /* ax = (al + ah * 10) & 0xff */
- movb %al, %bh /* bh = ascii->int conversion */
- jmp input_second_number
+ lodsb /* al = next char */
+ cmpb $0x30, %al
+ jc resize_end /* char < 0x30 invalid */
+ cmpb $0x3a, %al /* is char < 0x3a */
+ jnc input_final_r
+ andb $0x0f, %al /* al = 0 - 9 */
+ movb %bh, %ah /* ah = last conversion */
+ aad /* ax = (al + ah * 10) & 0xff */
+ movb %al, %bh /* bh = ascii->int conversion */
+ jmp input_second_number
input_final_r:
- cmpb $0x52, %al /* is al = 'R' ? */
- jnz suspect_loopback /* invalid input found */
- movb %bl, %cs:term_rows /* save away bl rows value */
- cmpw $0xc000, %cs:old_int10h_seg /* vga attached? */
- jz resize_end /* if so, leave term_cols at 80 */
- movb %bh, %cs:term_cols /* save away bh cols value */
- jmp resize_end
+ cmpb $0x52, %al /* is al = 'R' ? */
+ jnz suspect_loopback /* invalid input found */
+ movb %bl, %cs:term_rows /* save away bl rows value */
+ cmpw $0xc000, %cs:old_int10h_seg /* vga attached? */
+ jz resize_end /* if so, leave term_cols at 80 */
+ movb %bh, %cs:term_cols /* save away bh cols value */
+ jmp resize_end
suspect_loopback:
- /*
- * characters were received that look like what we sent out
- * at this point, assume that a loopback device was plugged in
- * and disable any future serial port reads or writes, by pointing
- * output to port 0x2e8 (COM4) instead of 0x3f8 -- it's expected
- * that this is safe since a real port responds correctly and a
- * missing port will respond with 0xff which will terminate the
- * loop that waits for the "right" status on the port.
- */
- movw $0x2e8, %cs:serial_port_base_address
+ /*
+ * characters were received that look like what we sent out
+ * at this point, assume that a loopback device was plugged in
+ * and disable any future serial port reads or writes, by pointing
+ * output to port 0x2e8 (COM4) instead of 0x3f8 -- it's expected
+ * that this is safe since a real port responds correctly and a
+ * missing port will respond with 0xff which will terminate the
+ * loop that waits for the "right" status on the port.
+ */
+ movw $0x2e8, %cs:serial_port_base_address
resize_end:
- /* clear (hopefully) overwritten cursor position buffer */
- xorb %al, %al
- movw $BDA_CURSOR_BUF, %di
- movw $0x10, %cx
- cld
- rep
- stosb /* fill 40:50 - 40:5f with 0 */
- pushw %cs
- popw %ds /* ds = cs */
- call get_byte /* flush any remaining "wrong" input */
- jnz resize_end
- call send_crlf /* place cursor on start of last line */
- movw $mfg_string, %si
- call send_asciz_out
- call send_crlf
- movw $prod_string, %si
- call send_asciz_out
- call send_crlf
- movw $long_version, %si
- call send_asciz_out
- call send_crlf
- /* if vga attached, skip terminal message and bda setup... */
- cmpw $0xc000, %cs:old_int10h_seg /* vga attached? */
- jz post_bda_init_tail /* if so, don't modify BDA */
- /* show detected terminal size, or default if none detected */
- movw $term_info, %si
- call send_asciz_out
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movb %cs:term_cols, %al
- movb %al, BDA_COLS /* 40:4a = number of character cols */
- movb $0, BDA_CURSOR_COL /* 40:51 = cursor0 col */
- call send_number
- movb $0x78, %al /* x */
- call send_byte
- movb %cs:term_rows, %al
- movb %al, %ah
- decb %ah /* ah = rows-1 */
- movb %ah, BDA_ROWS /* 40:84 = number of character rows - 1 */
- movb %ah, BDA_CURSOR_ROW /* 40:50 = cursor0 row */
- call send_number
- call send_crlf
- movb $3, BDA_MODE_NUM
- movb $0x29, BDA_MODE_SEL
- movw $VGA_IO_BASE, BDA_6845_ADDR
- movw $0x4000, BDA_PAGE_SIZE /* 16KB per video page */
- /* to avoid ansi colors every character, store last attribute */
- movb $0x07, BDA_COLOR_VAL /* 07 = black bg, white fg */
- movw %cs, %ax
- movw $_start, BDA_ROM_OFF
- movw %ax, BDA_ROM_SEG
+ /* clear (hopefully) overwritten cursor position buffer */
+ xorb %al, %al
+ movw $BDA_CURSOR_BUF, %di
+ movw $0x10, %cx
+ cld
+ rep
+ stosb /* fill 40:50 - 40:5f with 0 */
+ pushw %cs
+ popw %ds /* ds = cs */
+ call get_byte /* flush any remaining "wrong" input */
+ jnz resize_end
+ call send_crlf /* place cursor on start of last line */
+ movw $mfg_string, %si
+ call send_asciz_out
+ call send_crlf
+ movw $prod_string, %si
+ call send_asciz_out
+ call send_crlf
+ movw $long_version, %si
+ call send_asciz_out
+ call send_crlf
+ /* if vga attached, skip terminal message and bda setup... */
+ cmpw $0xc000, %cs:old_int10h_seg /* vga attached? */
+ jz post_bda_init_tail /* if so, don't modify BDA */
+ /* show detected terminal size, or default if none detected */
+ movw $term_info, %si
+ call send_asciz_out
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movb %cs:term_cols, %al
+ movb %al, BDA_COLS /* 40:4a = number of character cols */
+ movb $0, BDA_CURSOR_COL /* 40:51 = cursor0 col */
+ call send_number
+ movb $0x78, %al /* x */
+ call send_byte
+ movb %cs:term_rows, %al
+ movb %al, %ah
+ decb %ah /* ah = rows-1 */
+ movb %ah, BDA_ROWS /* 40:84 = num character rows - 1 */
+ movb %ah, BDA_CURSOR_ROW /* 40:50 = cursor0 row */
+ call send_number
+ call send_crlf
+ movb $3, BDA_MODE_NUM
+ movb $0x29, BDA_MODE_SEL
+ movw $VGA_IO_BASE, BDA_6845_ADDR
+ movw $0x4000, BDA_PAGE_SIZE /* 16KB per video page */
+ /* to avoid ansi colors every character, store last attribute */
+ movb $0x07, BDA_COLOR_VAL /* 07 = black bg, white fg */
+ movw %cs, %ax
+ movw $_start, BDA_ROM_OFF
+ movw %ax, BDA_ROM_SEG
post_bda_init_tail:
- /* copy BDA rows/cols to sgabios location... */
- /* if vga card is installed, reuse those values... */
- /* if no vga card is installed, this shouldn't change anything */
- pushw $BDA_SEG
- popw %ds /* ds = 0x40 */
- movb BDA_ROWS, %al
- incb %al /* bda holds rows-1 */
- movb %al, %cs:term_rows /* sgabios rows */
- movb BDA_COLS, %ah
- movb %ah, %cs:term_cols /* sgabios cols */
- /* setup in-memory logging of console if desired... */
- call setup_memconsole
- /* setup logging of last 256 characters output, if ebda has room */
- call sgabioslog_setup_ebda
- movw $ebda_info, %si
- call send_asciz_out
- movw %cs:sgabios_ebda_logbuf_offset, %ax
- xchgb %ah, %al
- call send_number
- movb $0x20, %al
- call send_byte
- movb %ah, %al
- call send_number
- call send_crlf
- popw %es
- popw %ds
- popaw
- popf
- lret
+ /* copy BDA rows/cols to sgabios location... */
+ /* if vga card is installed, reuse those values... */
+ /* if no vga card is installed, this shouldn't change anything */
+ pushw $BDA_SEG
+ popw %ds /* ds = 0x40 */
+ movb BDA_ROWS, %al
+ incb %al /* bda holds rows-1 */
+ movb %al, %cs:term_rows /* sgabios rows */
+ movb BDA_COLS, %ah
+ movb %ah, %cs:term_cols /* sgabios cols */
+ /* setup in-memory logging of console if desired... */
+ call setup_memconsole
+ /* setup logging of last 256 characters output, if ebda has room */
+ call sgabioslog_setup_ebda
+ movw $ebda_info, %si
+ call send_asciz_out
+ movw %cs:sgabios_ebda_logbuf_offset, %ax
+ xchgb %ah, %al
+ call send_number
+ movb $0x20, %al
+ call send_byte
+ movb %ah, %al
+ call send_number
+ call send_crlf
+ popw %es
+ popw %ds
+ popaw
+ popf
+ lret
_end_sgabios:
diff --git a/sgabios.h b/sgabios.h
new file mode 100644
index 0000000..51e829c
--- /dev/null
+++ b/sgabios.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* don't allocate ebda if new value at 0x40e will be less than this */
+#define EBDA_MIN_SEG 0x9800
+#define SGABIOS_EBDA_KB 1
+/* note: no testing has yet been done logging other than 256 bytes */
+#define SGABIOS_EBDA_BYTES (SGABIOS_EBDA_KB*1024)
+#define SGABIOS_EBDA_DELTA (SGABIOS_EBDA_BYTES/16)
+#define SGABIOS_EBDA_LOG_START 256
+#define SGABIOS_EBDA_LOG_SIZE 256
+#define SGABIOS_EBDA_POS_START (SGABIOS_EBDA_LOG_START+SGABIOS_EBDA_LOG_SIZE)
+#define SGABIOS_EBDA_POS_LAST (SGABIOS_EBDA_POS_START+(SGABIOS_EBDA_LOG_SIZE*2)-2)
+
+/* serial costants that may require modification */
+#define COM_BASE_ADDR 0x3f8
+#define PORT_SPEED 115200
+#define LCR_VALUE 0x13 /* 8n1 */
+
+/* serial constants below shouldn't require modification */
+#define IER_OFFSET 0x01
+#define FCR_OFFSET 0x02
+#define LCR_OFFSET 0x03
+#define MCR_OFFSET 0x04
+#define LSR_OFFSET 0x05
+#define MSR_OFFSET 0x06
+#define SCR_OFFSET 0x07
+#define LCR_DLAB 0x80
+#define MCR_DTRRTS 0x03
+#define FCR_FIFO_ENABLE 0x01
+#define PORT_DIVISOR 115200
+#define TRANSMIT_READY_BIT 0x20
+#define BIOS_BUILD_VERSION "$Id: sgabios.S 7 2009-11-13 00:21:26Z smiles@google.com $"
+
+#define KBD_HEAD 0x1a
+#define KBD_TAIL 0x1c
+#define KBD_BUF_START 0x1e
+#define KBD_BUF_END 0x3e
+
+#define VGA_IO_BASE 0x3d4
+#define BDA_SEG 0x40
+#define BDA_EBDA 0x0e
+#define BDA_MEM_SIZE 0x13
+#define BDA_MODE_NUM 0x49
+#define BDA_COLS 0x4a
+#define BDA_PAGE_SIZE 0x4c
+/* BDA word 40:0c traditionally holds the LPT3 io port address... */
+/* Reuse it for tracking where the serial console cursor was left */
+/* Don't send ansi cursor pos update without text ready to output */
+/* Some operations don't update cursor position, but next int 10h */
+/* call is often one that might update to where cursor already is */
+#define BDA_SERIAL_POS 0x0c
+#define BDA_CURSOR_BUF 0x50
+#define BDA_CURSOR_COL 0x50
+#define BDA_CURSOR_ROW 0x51
+#define BDA_CURSOR_SCAN 0x60
+#define BDA_ACTIVE_PAGE 0x62
+#define BDA_6845_ADDR 0x63
+#define BDA_MODE_SEL 0x65
+#define BDA_COLOR_VAL 0x66
+#define BDA_ROM_OFF 0x67
+#define BDA_ROM_SEG 0x69
+#define BDA_ROWS 0x84