From 21a0ded2844b4b2a48ac9eda8be86e6287da59d7 Mon Sep 17 00:00:00 2001 From: hpa Date: Mon, 26 Jul 2004 23:52:33 +0000 Subject: [PATCH] Move raw console access and strcpy() into their own include files --- isolinux.asm | 77 ++---------------------------------------------------------- pxelinux.asm | 77 ++---------------------------------------------------------- rawcon.inc | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ strcpy.inc | 12 ++++++++++ 4 files changed, 84 insertions(+), 150 deletions(-) create mode 100644 rawcon.inc create mode 100644 strcpy.inc diff --git a/isolinux.asm b/isolinux.asm index d1d250b..0e7d75f 100644 --- a/isolinux.asm +++ b/isolinux.asm @@ -1433,81 +1433,6 @@ iso_compare_names: .success: ret ; -; strcpy: Copy DS:SI -> ES:DI up to and including a null byte -; -strcpy: push ax -.loop: lodsb - stosb - and al,al - jnz .loop - pop ax - ret - -; -; writechr: Write a single character in AL to the console without -; mangling any registers. This does raw console writes, -; since some PXE BIOSes seem to interfere regular console I/O. -; -writechr_full: - push ds - push cs - pop ds - call write_serial ; write to serial port if needed - pushfd - pushad - mov bh,[BIOS_page] - push ax - mov ah,03h ; Read cursor position - int 10h - pop ax - cmp al,8 - je .bs - cmp al,13 - je .cr - cmp al,10 - je .lf - push dx - mov bh,[BIOS_page] - mov bl,07h ; White on black - mov cx,1 ; One only - mov ah,09h ; Write char and attribute - int 10h - pop dx - inc dl - cmp dl,[VidCols] - jna .curxyok - xor dl,dl -.lf: inc dh - cmp dh,[VidRows] - ja .scroll -.curxyok: mov bh,[BIOS_page] - mov ah,02h ; Set cursor position - int 10h -.ret: popad - popfd - pop ds - ret -.scroll: dec dh - mov bh,[BIOS_page] - mov ah,02h - int 10h - mov ax,0601h ; Scroll up one line - mov bh,[ScrollAttribute] - xor cx,cx - mov dx,[ScreenSize] ; The whole screen - int 10h - jmp short .ret -.cr: xor dl,dl - jmp short .curxyok -.bs: sub dl,1 - jnc .curxyok - mov dl,[VidCols] - sub dh,1 - jnc .curxyok - xor dh,dh - jmp short .curxyok - -; ; mangle_name: Mangle a filename pointed to by DS:SI into a buffer pointed ; to by ES:DI; ends on encountering any whitespace. ; @@ -1630,6 +1555,8 @@ getfssec: %include "font.inc" ; VGA font stuff %include "graphics.inc" ; VGA graphics %include "highmem.inc" ; High memory sizing +%include "strcpy.inc" ; strcpy() +%include "rawcon.inc" ; Console I/O w/o using the console functions ; ----------------------------------------------------------------------------- ; Begin data section diff --git a/pxelinux.asm b/pxelinux.asm index 58ae7e3..2140d5b 100644 --- a/pxelinux.asm +++ b/pxelinux.asm @@ -1487,81 +1487,6 @@ free_socket: ret ; -; strcpy: Copy DS:SI -> ES:DI up to and including a null byte -; -strcpy: push ax -.loop: lodsb - stosb - and al,al - jnz .loop - pop ax - ret - -; -; writechr: Write a single character in AL to the console without -; mangling any registers. This does raw console writes, -; since some PXE BIOSes seem to interfere regular console I/O. -; -writechr: - push ds - push cs - pop ds - call write_serial ; write to serial port if needed - pushfd - pushad - mov bh,[BIOS_page] - push ax - mov ah,03h ; Read cursor position - int 10h - pop ax - cmp al,8 - je .bs - cmp al,13 - je .cr - cmp al,10 - je .lf - push dx - mov bh,[BIOS_page] - mov bl,07h ; White on black - mov cx,1 ; One only - mov ah,09h ; Write char and attribute - int 10h - pop dx - inc dl - cmp dl,[VidCols] - jna .curxyok - xor dl,dl -.lf: inc dh - cmp dh,[VidRows] - ja .scroll -.curxyok: mov bh,[BIOS_page] - mov ah,02h ; Set cursor position - int 10h -.ret: popad - popfd - pop ds - ret -.scroll: dec dh - mov bh,[BIOS_page] - mov ah,02h - int 10h - mov ax,0601h ; Scroll up one line - mov bh,[ScrollAttribute] - xor cx,cx - mov dx,[ScreenSize] ; The whole screen - int 10h - jmp short .ret -.cr: xor dl,dl - jmp short .curxyok -.bs: sub dl,1 - jnc .curxyok - mov dl,[VidCols] - sub dh,1 - jnc .curxyok - xor dh,dh - jmp short .curxyok - -; ; mangle_name: Mangle a filename pointed to by DS:SI into a buffer pointed ; to by ES:DI; ends on encountering any whitespace. ; @@ -2366,6 +2291,8 @@ writestr equ cwritestr %include "font.inc" ; VGA font stuff %include "graphics.inc" ; VGA graphics %include "highmem.inc" ; High memory sizing +%include "strcpy.inc" ; strcpy() +%include "rawcon.inc" ; Console I/O w/o using the console functions ; ----------------------------------------------------------------------------- ; Begin data section diff --git a/rawcon.inc b/rawcon.inc new file mode 100644 index 0000000..87e69fa --- /dev/null +++ b/rawcon.inc @@ -0,0 +1,68 @@ +; +; writechr: Write a single character in AL to the console without +; mangling any registers. This does raw console writes, +; since some PXE BIOSes seem to interfere regular console I/O. +; +%if IS_ISOLINUX +writechr_full: +%else +writechr: +%endif + push ds + push cs + pop ds + call write_serial ; write to serial port if needed + pushfd + pushad + mov bh,[BIOS_page] + push ax + mov ah,03h ; Read cursor position + int 10h + pop ax + cmp al,8 + je .bs + cmp al,13 + je .cr + cmp al,10 + je .lf + push dx + mov bh,[BIOS_page] + mov bl,07h ; White on black + mov cx,1 ; One only + mov ah,09h ; Write char and attribute + int 10h + pop dx + inc dl + cmp dl,[VidCols] + jna .curxyok + xor dl,dl +.lf: inc dh + cmp dh,[VidRows] + ja .scroll +.curxyok: mov bh,[BIOS_page] + mov ah,02h ; Set cursor position + int 10h +.ret: popad + popfd + pop ds + ret +.scroll: dec dh + mov bh,[BIOS_page] + mov ah,02h + int 10h + mov ax,0601h ; Scroll up one line + mov bh,[ScrollAttribute] + xor cx,cx + mov dx,[ScreenSize] ; The whole screen + int 10h + jmp short .ret +.cr: xor dl,dl + jmp short .curxyok +.bs: sub dl,1 + jnc .curxyok + mov dl,[VidCols] + sub dh,1 + jnc .curxyok + xor dh,dh + jmp short .curxyok + diff --git a/strcpy.inc b/strcpy.inc new file mode 100644 index 0000000..beb5954 --- /dev/null +++ b/strcpy.inc @@ -0,0 +1,12 @@ +; +; strcpy: Copy DS:SI -> ES:DI up to and including a null byte; +; on exit SI and DI point to the byte *after* the null byte +; +strcpy: push ax +.loop: lodsb + stosb + and al,al + jnz .loop + pop ax + ret + -- 2.7.4