From 04144d623ef98e6e25df53113625e94fe7994269 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 19 Jul 2004 01:25:02 +0000 Subject: [PATCH] Consolidate most constant memory addresses in bootasm.h part2/2: Convert btx/lib and do additional cleanups. Again no operational changes. --- sys/boot/i386/boot2/Makefile | 9 +++- sys/boot/i386/boot2/boot1.S | 30 ++++++----- sys/boot/i386/bootasm.h | 32 +++++++----- sys/boot/i386/btx/btx/btx.S | 8 ++- sys/boot/i386/btx/btxldr/btxldr.S | 36 ++++++------- sys/boot/i386/btx/lib/btxcsu.S | 70 ++++++++++++------------- sys/boot/i386/btx/lib/btxcsu.s | 44 ---------------- sys/boot/i386/btx/lib/btxsys.S | 75 +++++++++++++++------------ sys/boot/i386/btx/lib/btxsys.s | 41 --------------- sys/boot/i386/btx/lib/btxv86.S | 83 ++++++++++++++++------------- sys/boot/i386/btx/lib/btxv86.s | 86 ------------------------------- sys/boot/pc32/boot2/Makefile | 9 +++- sys/boot/pc32/boot2/boot1.S | 30 ++++++----- sys/boot/pc32/bootasm.h | 32 +++++++----- sys/boot/pc32/btx/btx/btx.S | 8 ++- sys/boot/pc32/btx/btxldr/btxldr.S | 36 ++++++------- sys/boot/pc32/btx/lib/btxcsu.S | 70 ++++++++++++------------- sys/boot/pc32/btx/lib/btxsys.S | 75 +++++++++++++++------------ sys/boot/pc32/btx/lib/btxv86.S | 83 ++++++++++++++++------------- 19 files changed, 382 insertions(+), 475 deletions(-) delete mode 100644 sys/boot/i386/btx/lib/btxcsu.s delete mode 100644 sys/boot/i386/btx/lib/btxsys.s delete mode 100644 sys/boot/i386/btx/lib/btxv86.s diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index b0461e2050..72360ada9c 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.47 2003/06/26 03:51:57 peter Exp $ -# $DragonFly: src/sys/boot/i386/boot2/Attic/Makefile,v 1.7 2004/07/18 23:40:01 dillon Exp $ +# $DragonFly: src/sys/boot/i386/boot2/Attic/Makefile,v 1.8 2004/07/19 01:24:58 dillon Exp $ PROG= boot2 NOMAN= @@ -25,8 +25,15 @@ BTX= ${.OBJDIR}/../btx BTX= ${.CURDIR}/../btx .endif +# WARNING! These constants are also defined in bootasm.h +# REL1= 0x700 ORG1= 0x7c00 + +# WARNING! The ORG2 calculation is the origin of boot2.bin relative to +# the start of the BTX *USER* address space, not the start of physical +# memory. +# ORG2= 0x2000 # Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit. diff --git a/sys/boot/i386/boot2/boot1.S b/sys/boot/i386/boot2/boot1.S index ba0d16952f..6aa12cb858 100644 --- a/sys/boot/i386/boot2/boot1.S +++ b/sys/boot/i386/boot2/boot1.S @@ -13,7 +13,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/boot2/boot1.s,v 1.23 2003/08/22 01:59:28 imp Exp $ - * $DragonFly: src/sys/boot/i386/boot2/Attic/boot1.S,v 1.5 2004/07/18 23:40:01 dillon Exp $ + * $DragonFly: src/sys/boot/i386/boot2/Attic/boot1.S,v 1.6 2004/07/19 01:24:58 dillon Exp $ */ #include "../bootasm.h" @@ -137,7 +137,7 @@ main: cld // String ops inc movb $0x1,%dh // Block count callw nread // Read MBR mov $0x1,%cx // Two passes -main.1: mov $MEM_BUF+PRT_OFF,%si // Partition table +main.1: mov $BOOT2_LOAD_BUF+PRT_OFF,%si // Partition table movb $0x1,%dh // Partition main.2: cmpb $PRT_BSD,0x4(%si) // Our partition type? jne main.3 // No @@ -163,25 +163,29 @@ main.4: xor %dx,%dx // Partition:drive // // Ok, we have a slice and drive in %dx now, so use that to locate and load // boot2. %si references the start of the slice we are looking for, so go -// ahead and load up the first 16 sectors (boot1 + boot2) from that. When -// we read it in, we conveniently use 0x8c00 as our transfer buffer. Thus, -// boot1 ends up at 0x8c00, and boot2 starts at 0x8c00 + 0x200 = 0x8e00. +// ahead and load up the first 16 sectors (boot1 + boot2) from that. +// +// When we read it in, we conveniently use BOOT2_LOAD_BUF (0x8c00) as our +// transfer buffer. Thus, boot1 ends up at 0x8c00, and boot2 starts at +// 0x8c00 + 0x200 = 0x8e00. +// // The first part of boot2 is the disklabel, which is 0x200 bytes long. // The second part is BTX, which is thus loaded into 0x9000, which is where // it also runs from. The boot2.bin binary starts right after the end of // BTX, so we have to figure out where the start of it is and then move the -// binary to 0xc000. Normally, BTX clients start at MEM_USR, or 0xa000, but -// when we use btxld to create boot2, we use an entry point of 0x2000. That -// entry point is relative to MEM_USR; thus boot2.bin starts at 0xc000. +// binary to 0xc000. Normally, BTX clients start at MEM_BTX_USR, or 0xa000, +// but when we use btxld to create boot2, we use an entry point of 0x2000. +// That entry point is relative to MEM_BTX_USR; thus boot2.bin starts +// at 0xc000. // main.5: mov %dx,MEM_ARG // Save args movb $NSECT,%dh // Sector count callw nread // Read disk - mov $MEM_BTX,%bx // BTX + mov $MEM_BTX_ORG,%bx // BTX mov 0xa(%bx),%si // Get BTX length and set add %bx,%si // %si to start of boot2.bin - mov $MEM_USR+SIZ_PAG*2,%di // Client page 2 - mov $MEM_BTX+(NSECT-1)*SIZ_SEC,%cx // Byte + mov $MEM_BTX_USR+SIZ_PAG*2,%di // Client page 2 + mov $MEM_BTX_ORG+(NSECT-1)*SIZ_SEC,%cx // Byte sub %si,%cx // count rep // Relocate movsb // client @@ -190,7 +194,7 @@ main.5: mov %dx,MEM_ARG // Save args rep // the end of boot2.bin stosb // up to 0x10000 callw seta20 // Enable A20 - jmp start+MEM_JMP-MEM_ORG // Start BTX + jmp start+MEM_BTX_ENTRY-MEM_ORG // Start BTX // // Enable A20 so we can access memory above 1 meg. // @@ -210,7 +214,7 @@ seta20.2: inb $0x64,%al // Get status // // Trampoline used to call read from within boot1. // -nread: mov $MEM_BUF,%bx // Transfer buffer +nread: mov $BOOT2_LOAD_BUF,%bx // Transfer buffer mov 0x8(%si),%ax // Get mov 0xa(%si),%cx // LBA push %cs // Read from diff --git a/sys/boot/i386/bootasm.h b/sys/boot/i386/bootasm.h index da8cefc342..ad6c918a33 100644 --- a/sys/boot/i386/bootasm.h +++ b/sys/boot/i386/bootasm.h @@ -31,24 +31,26 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/boot/i386/Attic/bootasm.h,v 1.1 2004/07/18 23:39:55 dillon Exp $ + * $DragonFly: src/sys/boot/i386/Attic/bootasm.h,v 1.2 2004/07/19 01:24:57 dillon Exp $ */ +/* + * NOTE: MEM_REL and MEM_ORG also defined in boot2/Makefile + */ #define NHRDRV 0x475 #define BOOT0_ORIGIN 0x600 /* boot0 relocated */ #define FAKE 0x800 /* Fake partition entry */ #define LOAD 0x7c00 /* Load address */ - +#define BOOTINFO_SIZE 0x48 /* bootinfo structure size */ #define MEM_ARG_SIZE 0x18 #define MEM_PAGE_SIZE 0x1000 +#define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */ +#define USR_ARGOFFSET (BOOTINFO_SIZE+MEM_ARG_SIZE) #define MEM_REL 0x700 /* Relocation address */ #define MEM_ARG 0x900 /* Arguments */ #define MEM_ORG 0x7c00 /* Origin */ -#define MEM_BUF 0x8c00 /* Load area */ -#define MEM_BTX 0x9000 /* BTX start */ -#define MEM_JMP 0x9010 /* BTX entry point */ -#define MEM_USR 0xa000 /* Client start */ + #define BDA_BOOT 0x472 /* Boot howto flag */ #define BDA_MEM 0x413 /* Free memory */ #define BDA_KEYFLAGS 0x417 /* Keyboard shift-state flags */ @@ -56,6 +58,7 @@ #define BDA_POS 0x450 /* Cursor position */ #define BDA_KEYBOARD 0x496 /* BDA byte with keyboard bit */ +#define MEM_BTX_ESP 0x1000 /* btxldr top of stack? */ #define MEM_BTX_START 0x1000 /* start of BTX memory */ #define MEM_BTX_ESP0 0x1800 /* Supervisor stack */ #define MEM_BTX_BUF 0x1800 /* Scratch buffer stack */ @@ -64,15 +67,20 @@ #define MEM_BTX_TSS 0x1f98 /* TSS */ #define MEM_BTX_MAP 0x2000 /* I/O bit map */ #define MEM_BTX_DIR 0x4000 /* Page directory */ + +/* + * NOTE: page table location is hardwired in /usr/src/usr.sbin/btxld/btx.h + */ #define MEM_BTX_TBL 0x5000 /* Page tables */ + +/* + * NOTE: BOOT2_LOAD_BUF also determines where the btx loader and boot2.bin + * code are loaded, since they are all in the boot2 file. + */ +#define BOOT2_LOAD_BUF 0x8c00 /* boot1 loads boot2 */ #define MEM_BTX_ORG 0x9000 /* base of BTX code */ #define MEM_BTX_ENTRY 0x9010 /* BTX starts execution here */ #define MEM_BTX_USR 0xa000 /* base of BTX client/user memory */ #define MEM_BTX_USR_ARG 0xa100 -#define MEM_BTX_LDR_OFF MEM_PAGE_SIZE /* offset of btx in the loader - -/* - * CDBOOT - */ -#define MEM_BTX_LDR_OFFSET 0x1000 /* Offset of BTX in the loader */ +#define MEM_BTX_LDR_OFF MEM_PAGE_SIZE /* offset of btx in the loader */ diff --git a/sys/boot/i386/btx/btx/btx.S b/sys/boot/i386/btx/btx/btx.S index cd17e9cf9a..017623b4b0 100644 --- a/sys/boot/i386/btx/btx/btx.S +++ b/sys/boot/i386/btx/btx/btx.S @@ -13,7 +13,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/btx/btx/btx.s,v 1.32 2002/10/08 18:19:02 jhb Exp $ - * $DragonFly: src/sys/boot/i386/btx/btx/Attic/btx.S,v 1.5 2004/07/18 23:40:04 dillon Exp $ + * $DragonFly: src/sys/boot/i386/btx/btx/Attic/btx.S,v 1.6 2004/07/19 01:25:00 dillon Exp $ */ #include "../../bootasm.h" @@ -217,10 +217,14 @@ init.8: xorl %ecx,%ecx # Zero */ movb $SEL_TSS,%cl # Set task ltr %cx # register + /* + * XXX We should NOT use BDA_MEM here. Use a fixed location + * instead. + */ movl $MEM_BTX_USR,%edx # User base address movzwl %ss:BDA_MEM,%eax # Get free memory shll $0xa,%eax # To bytes - subl $0x1000,%eax # Less arg space + subl $USR_ARGSPACE,%eax # Less arg space subl %edx,%eax # Less base movb $SEL_UDATA,%cl # User data selector pushl %ecx # Set SS diff --git a/sys/boot/i386/btx/btxldr/btxldr.S b/sys/boot/i386/btx/btxldr/btxldr.S index ff75293eb2..f6d1cca086 100644 --- a/sys/boot/i386/btx/btxldr/btxldr.S +++ b/sys/boot/i386/btx/btxldr/btxldr.S @@ -13,7 +13,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/btx/btxldr/Makefile,v 1.17 2004/04/27 19:45:16 ru Exp $ - * $DragonFly: src/sys/boot/i386/btx/btxldr/Attic/btxldr.S,v 1.1 2004/06/25 00:38:38 dillon Exp $ + * $DragonFly: src/sys/boot/i386/btx/btxldr/Attic/btxldr.S,v 1.2 2004/07/19 01:25:01 dillon Exp $ */ /* @@ -21,13 +21,10 @@ * real thing should probably be more flexible, and in C. */ +#include "../../bootasm.h" /* * Memory locations. */ - .set MEM_STUB,0x600 # Real mode stub - .set MEM_ESP,0x1000 # New stack pointer - .set MEM_TBL,0x5000 # BTX page tables - .set MEM_ENTRY,0x9010 # BTX entry point .set MEM_DATA,start+0x1000 # Data segment /* * Segment selectors. @@ -47,12 +44,6 @@ .set SCR_MAT,0x7 # Mode/attribute .set SCR_COL,0x50 # Columns per row .set SCR_ROW,0x19 # Rows per screen -/* - * BIOS Data Area locations. - */ - .set BDA_MEM,0x413 # Free memory - .set BDA_SCR,0x449 # Video mode - .set BDA_POS,0x450 # Cursor position /* * Required by aout gas inadequacy. */ @@ -68,7 +59,7 @@ start: cld # String ops inc movl $m_logo,%esi # Identify call putstr # ourselves movzwl BDA_MEM,%eax # Get base memory - shll $0xa,%eax # in bytes + shll $0xa,%eax # Convert to bytes movl %eax,%ebp # Base of user stack #ifdef BTXLDR_VERBOSE movl $m_mem,%esi # Display @@ -93,7 +84,16 @@ start.1: movl (%ebx),%eax # Get argument and loop start.1 # Till done call putstr # End message #endif - movl $0x48,%ecx # Allocate space + /* + * Arguments: (entry, boothowto, bootdev, 0, 0, 0, bootinfo) + * 0x00, 0x04, 0x08, 0x18 + * + * sizeof(bootinfo) == 0x48 (BOOTINFO_SIZE) + * sizeof arguments == 0x18 (MEM_ARG_SIZE) + * total arguments == 0x60 bytes (USR_ARGOFFSET) + */ + + movl $BOOTINFO_SIZE,%ecx # Allocate space subl %ecx,%ebp # for bootinfo movl 0x18(%esp,1),%esi # Source: bootinfo cmpl $0x0, %esi # If the bootinfo pointer @@ -123,7 +123,7 @@ start_null_bi: movl $0x18,%ecx # Allocate space /* * Set up BTX kernel. */ - movl $MEM_ESP,%esp # Set up new stack + movl $MEM_BTX_ESP,%esp # Set up new stack movl $MEM_DATA,%ebx # Data segment movl $m_vers,%esi # Display BTX call putstr # version message @@ -147,7 +147,7 @@ start_null_bi: movl $0x18,%ecx # Allocate space orl $PAG_SIZ/PAG_ENT-1,%edi # the incl %edi # BTX shll $0x2,%edi # load - addl $MEM_TBL,%edi # address + addl $MEM_BTX_TBL,%edi # address pushl %edi # Save load address movzwl 0xa(%ebx),%ecx # Image size #ifdef BTXLDR_VERBOSE @@ -234,11 +234,11 @@ start.7: call putstr # message #endif movl $start.8,%esi # Real mode stub - movl $MEM_STUB,%edi # Destination + movl $BOOT0_ORIGIN,%edi # Destination movl $start.9-start.8,%ecx # Size rep # Relocate movsb # it - ljmp $SEL_RCODE,$MEM_STUB # To 16-bit code + ljmp $SEL_RCODE,$BOOT0_ORIGIN # To 16-bit code .code16 start.8: xorw %ax,%ax # Data movb $SEL_RDATA,%al # selector @@ -250,7 +250,7 @@ start.8: xorw %ax,%ax # Data movl %cr0,%eax # Switch to decw %ax # real movl %eax,%cr0 # mode - ljmp $0,$MEM_ENTRY # Jump to BTX entry point + ljmp $0,$MEM_BTX_ENTRY # Jump to BTX entry point start.9: .code32 /* diff --git a/sys/boot/i386/btx/lib/btxcsu.S b/sys/boot/i386/btx/lib/btxcsu.S index 21ab709666..cf58b7ccd8 100644 --- a/sys/boot/i386/btx/lib/btxcsu.S +++ b/sys/boot/i386/btx/lib/btxcsu.S @@ -1,44 +1,44 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * $FreeBSD: src/sys/boot/i386/btx/lib/btxcsu.s,v 1.3 1999/08/28 00:40:07 peter Exp $ + * $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxcsu.S,v 1.4 2004/07/19 01:25:02 dillon Exp $ + */ -# $FreeBSD: src/sys/boot/i386/btx/lib/btxcsu.s,v 1.3 1999/08/28 00:40:07 peter Exp $ -# $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxcsu.S,v 1.3 2003/11/10 06:08:35 dillon Exp $ +/* + * BTX C startup code (ELF). + */ -# -# BTX C startup code (ELF). -# +#include "../../bootasm.h" -# -# Globals. -# + /* + * Globals. + */ .global _start -# -# Constants. -# - .set ARGADJ,0xfa0 # Argument adjustment -# -# Client entry point. -# + + /* + * Client entry point. + */ _start: movl %eax,__base # Set base address - movl %esp,%eax # Set - addl $ARGADJ,%eax # argument - movl %eax,__args # pointer + movl %esp,%eax # Get base of arguments + addl $USR_ARGSPACE-USR_ARGOFFSET,%eax + movl %eax,__args call main # Invoke client main() call exit # Invoke client exit() -# -# Data. -# + + /* + * Data + */ .comm __base,4 # Client base address .comm __args,4 # Client arguments diff --git a/sys/boot/i386/btx/lib/btxcsu.s b/sys/boot/i386/btx/lib/btxcsu.s deleted file mode 100644 index 8b513a2429..0000000000 --- a/sys/boot/i386/btx/lib/btxcsu.s +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# - -# $FreeBSD: src/sys/boot/i386/btx/lib/btxcsu.s,v 1.3 1999/08/28 00:40:07 peter Exp $ -# $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxcsu.s,v 1.3 2003/11/10 06:08:35 dillon Exp $ - -# -# BTX C startup code (ELF). -# - -# -# Globals. -# - .global _start -# -# Constants. -# - .set ARGADJ,0xfa0 # Argument adjustment -# -# Client entry point. -# -_start: movl %eax,__base # Set base address - movl %esp,%eax # Set - addl $ARGADJ,%eax # argument - movl %eax,__args # pointer - call main # Invoke client main() - call exit # Invoke client exit() -# -# Data. -# - .comm __base,4 # Client base address - .comm __args,4 # Client arguments diff --git a/sys/boot/i386/btx/lib/btxsys.S b/sys/boot/i386/btx/lib/btxsys.S index 2b812c51c7..571d8124a3 100644 --- a/sys/boot/i386/btx/lib/btxsys.S +++ b/sys/boot/i386/btx/lib/btxsys.S @@ -1,41 +1,48 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# - -# $FreeBSD: src/sys/boot/i386/btx/lib/btxsys.s,v 1.2 1999/08/28 00:40:07 peter Exp $ -# $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxsys.S,v 1.3 2003/11/10 06:08:35 dillon Exp $ - -# -# BTX system calls. -# - -# -# Globals. -# +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * $FreeBSD: src/sys/boot/i386/btx/lib/btxsys.s,v 1.2 1999/08/28 00:40:07 peter Exp $ + * $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxsys.S,v 1.4 2004/07/19 01:25:02 dillon Exp $ + */ + +/* + * BTX system calls. + */ + +#include "../../bootasm.h" + + /* + * Globals. + */ .global __exit .global __exec -# -# Constants. -# + + /* + * Constants. + */ .set INT_SYS,0x30 # Interrupt number -# -# System call: exit -# + + /* + * System call: exit + */ __exit: xorl %eax,%eax # BTX system int $INT_SYS # call 0x0 -# -# System call: exec -# + + /* + * System call: exec + */ __exec: movl $0x1,%eax # BTX system int $INT_SYS # call 0x1 + + diff --git a/sys/boot/i386/btx/lib/btxsys.s b/sys/boot/i386/btx/lib/btxsys.s deleted file mode 100644 index 8e16378ceb..0000000000 --- a/sys/boot/i386/btx/lib/btxsys.s +++ /dev/null @@ -1,41 +0,0 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# - -# $FreeBSD: src/sys/boot/i386/btx/lib/btxsys.s,v 1.2 1999/08/28 00:40:07 peter Exp $ -# $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxsys.s,v 1.3 2003/11/10 06:08:35 dillon Exp $ - -# -# BTX system calls. -# - -# -# Globals. -# - .global __exit - .global __exec -# -# Constants. -# - .set INT_SYS,0x30 # Interrupt number -# -# System call: exit -# -__exit: xorl %eax,%eax # BTX system - int $INT_SYS # call 0x0 -# -# System call: exec -# -__exec: movl $0x1,%eax # BTX system - int $INT_SYS # call 0x1 diff --git a/sys/boot/i386/btx/lib/btxv86.S b/sys/boot/i386/btx/lib/btxv86.S index f3d5c3a5e7..99319b08df 100644 --- a/sys/boot/i386/btx/lib/btxv86.S +++ b/sys/boot/i386/btx/lib/btxv86.S @@ -1,32 +1,36 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * + * $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3 1999/08/28 00:40:08 peter Exp $ + * $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxv86.S,v 1.4 2004/07/19 01:25:02 dillon Exp $ + */ -# $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3 1999/08/28 00:40:08 peter Exp $ -# $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxv86.S,v 1.3 2003/11/10 06:08:35 dillon Exp $ +/* + * BTX V86 interface. + */ -# -# BTX V86 interface. -# +#include "../../bootasm.h" -# -# Globals. -# + /* + * Globals. + */ .global __v86int -# -# Fields in V86 interface structure. -# + + /* + * Fields in V86 interface structure. + */ .set V86_CTL,0x0 # Control flags .set V86_ADDR,0x4 # Int number/address .set V86_ES,0x8 # V86 ES @@ -41,14 +45,16 @@ .set V86_EBP,0x2c # V86 EBP .set V86_ESI,0x30 # V86 ESI .set V86_EDI,0x34 # V86 EDI -# -# Other constants. -# + + /* + * Other constants. + */ .set INT_V86,0x31 # Interrupt number .set SIZ_V86,0x38 # Size of V86 structure -# -# V86 interface function. -# + + /* + * V86 interface function. + */ __v86int: popl __v86ret # Save return address pushl $__v86 # Push pointer call __v86_swap # Load V86 registers @@ -57,9 +63,10 @@ __v86int: popl __v86ret # Save return address addl $0x4,%esp # Discard pointer pushl __v86ret # Restore return address ret # To user -# -# Swap V86 and user registers. -# + + /* + * Swap V86 and user registers. + */ __v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP xchgl %eax,V86_EAX(%ebp) # Swap EAX xchgl %ecx,V86_ECX(%ebp) # Swap ECX @@ -79,8 +86,10 @@ __v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP xchgl %edi,V86_EDI(%ebp) # Swap EDI xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP ret # To caller -# -# V86 interface structure. -# + + /* + * V86 interface structure. + */ .comm __v86,SIZ_V86 .comm __v86ret,4 + diff --git a/sys/boot/i386/btx/lib/btxv86.s b/sys/boot/i386/btx/lib/btxv86.s deleted file mode 100644 index 860e9574a0..0000000000 --- a/sys/boot/i386/btx/lib/btxv86.s +++ /dev/null @@ -1,86 +0,0 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# - -# $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3 1999/08/28 00:40:08 peter Exp $ -# $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxv86.s,v 1.3 2003/11/10 06:08:35 dillon Exp $ - -# -# BTX V86 interface. -# - -# -# Globals. -# - .global __v86int -# -# Fields in V86 interface structure. -# - .set V86_CTL,0x0 # Control flags - .set V86_ADDR,0x4 # Int number/address - .set V86_ES,0x8 # V86 ES - .set V86_DS,0xc # V86 DS - .set V86_FS,0x10 # V86 FS - .set V86_GS,0x14 # V86 GS - .set V86_EAX,0x18 # V86 EAX - .set V86_ECX,0x1c # V86 ECX - .set V86_EDX,0x20 # V86 EDX - .set V86_EBX,0x24 # V86 EBX - .set V86_EFL,0x28 # V86 eflags - .set V86_EBP,0x2c # V86 EBP - .set V86_ESI,0x30 # V86 ESI - .set V86_EDI,0x34 # V86 EDI -# -# Other constants. -# - .set INT_V86,0x31 # Interrupt number - .set SIZ_V86,0x38 # Size of V86 structure -# -# V86 interface function. -# -__v86int: popl __v86ret # Save return address - pushl $__v86 # Push pointer - call __v86_swap # Load V86 registers - int $INT_V86 # To BTX - call __v86_swap # Load user registers - addl $0x4,%esp # Discard pointer - pushl __v86ret # Restore return address - ret # To user -# -# Swap V86 and user registers. -# -__v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP - xchgl %eax,V86_EAX(%ebp) # Swap EAX - xchgl %ecx,V86_ECX(%ebp) # Swap ECX - xchgl %edx,V86_EDX(%ebp) # Swap EDX - xchgl %ebx,V86_EBX(%ebp) # Swap EBX - pushl %eax # Save - pushf # Put eflags - popl %eax # in EAX - xchgl %eax,V86_EFL(%ebp) # Swap - pushl %eax # Put EAX - popf # in eflags - movl 0x8(%esp,1),%eax # Load EBP - xchgl %eax,V86_EBP(%ebp) # Swap - movl %eax,0x8(%esp,1) # Save EBP - popl %eax # Restore - xchgl %esi,V86_ESI(%ebp) # Swap ESI - xchgl %edi,V86_EDI(%ebp) # Swap EDI - xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP - ret # To caller -# -# V86 interface structure. -# - .comm __v86,SIZ_V86 - .comm __v86ret,4 diff --git a/sys/boot/pc32/boot2/Makefile b/sys/boot/pc32/boot2/Makefile index e7ba78bbac..7915a8b242 100644 --- a/sys/boot/pc32/boot2/Makefile +++ b/sys/boot/pc32/boot2/Makefile @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.47 2003/06/26 03:51:57 peter Exp $ -# $DragonFly: src/sys/boot/pc32/boot2/Makefile,v 1.7 2004/07/18 23:40:01 dillon Exp $ +# $DragonFly: src/sys/boot/pc32/boot2/Makefile,v 1.8 2004/07/19 01:24:58 dillon Exp $ PROG= boot2 NOMAN= @@ -25,8 +25,15 @@ BTX= ${.OBJDIR}/../btx BTX= ${.CURDIR}/../btx .endif +# WARNING! These constants are also defined in bootasm.h +# REL1= 0x700 ORG1= 0x7c00 + +# WARNING! The ORG2 calculation is the origin of boot2.bin relative to +# the start of the BTX *USER* address space, not the start of physical +# memory. +# ORG2= 0x2000 # Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit. diff --git a/sys/boot/pc32/boot2/boot1.S b/sys/boot/pc32/boot2/boot1.S index 9a31992af1..4413a66046 100644 --- a/sys/boot/pc32/boot2/boot1.S +++ b/sys/boot/pc32/boot2/boot1.S @@ -13,7 +13,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/boot2/boot1.s,v 1.23 2003/08/22 01:59:28 imp Exp $ - * $DragonFly: src/sys/boot/pc32/boot2/boot1.S,v 1.5 2004/07/18 23:40:01 dillon Exp $ + * $DragonFly: src/sys/boot/pc32/boot2/boot1.S,v 1.6 2004/07/19 01:24:58 dillon Exp $ */ #include "../bootasm.h" @@ -137,7 +137,7 @@ main: cld // String ops inc movb $0x1,%dh // Block count callw nread // Read MBR mov $0x1,%cx // Two passes -main.1: mov $MEM_BUF+PRT_OFF,%si // Partition table +main.1: mov $BOOT2_LOAD_BUF+PRT_OFF,%si // Partition table movb $0x1,%dh // Partition main.2: cmpb $PRT_BSD,0x4(%si) // Our partition type? jne main.3 // No @@ -163,25 +163,29 @@ main.4: xor %dx,%dx // Partition:drive // // Ok, we have a slice and drive in %dx now, so use that to locate and load // boot2. %si references the start of the slice we are looking for, so go -// ahead and load up the first 16 sectors (boot1 + boot2) from that. When -// we read it in, we conveniently use 0x8c00 as our transfer buffer. Thus, -// boot1 ends up at 0x8c00, and boot2 starts at 0x8c00 + 0x200 = 0x8e00. +// ahead and load up the first 16 sectors (boot1 + boot2) from that. +// +// When we read it in, we conveniently use BOOT2_LOAD_BUF (0x8c00) as our +// transfer buffer. Thus, boot1 ends up at 0x8c00, and boot2 starts at +// 0x8c00 + 0x200 = 0x8e00. +// // The first part of boot2 is the disklabel, which is 0x200 bytes long. // The second part is BTX, which is thus loaded into 0x9000, which is where // it also runs from. The boot2.bin binary starts right after the end of // BTX, so we have to figure out where the start of it is and then move the -// binary to 0xc000. Normally, BTX clients start at MEM_USR, or 0xa000, but -// when we use btxld to create boot2, we use an entry point of 0x2000. That -// entry point is relative to MEM_USR; thus boot2.bin starts at 0xc000. +// binary to 0xc000. Normally, BTX clients start at MEM_BTX_USR, or 0xa000, +// but when we use btxld to create boot2, we use an entry point of 0x2000. +// That entry point is relative to MEM_BTX_USR; thus boot2.bin starts +// at 0xc000. // main.5: mov %dx,MEM_ARG // Save args movb $NSECT,%dh // Sector count callw nread // Read disk - mov $MEM_BTX,%bx // BTX + mov $MEM_BTX_ORG,%bx // BTX mov 0xa(%bx),%si // Get BTX length and set add %bx,%si // %si to start of boot2.bin - mov $MEM_USR+SIZ_PAG*2,%di // Client page 2 - mov $MEM_BTX+(NSECT-1)*SIZ_SEC,%cx // Byte + mov $MEM_BTX_USR+SIZ_PAG*2,%di // Client page 2 + mov $MEM_BTX_ORG+(NSECT-1)*SIZ_SEC,%cx // Byte sub %si,%cx // count rep // Relocate movsb // client @@ -190,7 +194,7 @@ main.5: mov %dx,MEM_ARG // Save args rep // the end of boot2.bin stosb // up to 0x10000 callw seta20 // Enable A20 - jmp start+MEM_JMP-MEM_ORG // Start BTX + jmp start+MEM_BTX_ENTRY-MEM_ORG // Start BTX // // Enable A20 so we can access memory above 1 meg. // @@ -210,7 +214,7 @@ seta20.2: inb $0x64,%al // Get status // // Trampoline used to call read from within boot1. // -nread: mov $MEM_BUF,%bx // Transfer buffer +nread: mov $BOOT2_LOAD_BUF,%bx // Transfer buffer mov 0x8(%si),%ax // Get mov 0xa(%si),%cx // LBA push %cs // Read from diff --git a/sys/boot/pc32/bootasm.h b/sys/boot/pc32/bootasm.h index 5b159c04aa..be5bf43cee 100644 --- a/sys/boot/pc32/bootasm.h +++ b/sys/boot/pc32/bootasm.h @@ -31,24 +31,26 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/boot/pc32/bootasm.h,v 1.1 2004/07/18 23:39:55 dillon Exp $ + * $DragonFly: src/sys/boot/pc32/bootasm.h,v 1.2 2004/07/19 01:24:57 dillon Exp $ */ +/* + * NOTE: MEM_REL and MEM_ORG also defined in boot2/Makefile + */ #define NHRDRV 0x475 #define BOOT0_ORIGIN 0x600 /* boot0 relocated */ #define FAKE 0x800 /* Fake partition entry */ #define LOAD 0x7c00 /* Load address */ - +#define BOOTINFO_SIZE 0x48 /* bootinfo structure size */ #define MEM_ARG_SIZE 0x18 #define MEM_PAGE_SIZE 0x1000 +#define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */ +#define USR_ARGOFFSET (BOOTINFO_SIZE+MEM_ARG_SIZE) #define MEM_REL 0x700 /* Relocation address */ #define MEM_ARG 0x900 /* Arguments */ #define MEM_ORG 0x7c00 /* Origin */ -#define MEM_BUF 0x8c00 /* Load area */ -#define MEM_BTX 0x9000 /* BTX start */ -#define MEM_JMP 0x9010 /* BTX entry point */ -#define MEM_USR 0xa000 /* Client start */ + #define BDA_BOOT 0x472 /* Boot howto flag */ #define BDA_MEM 0x413 /* Free memory */ #define BDA_KEYFLAGS 0x417 /* Keyboard shift-state flags */ @@ -56,6 +58,7 @@ #define BDA_POS 0x450 /* Cursor position */ #define BDA_KEYBOARD 0x496 /* BDA byte with keyboard bit */ +#define MEM_BTX_ESP 0x1000 /* btxldr top of stack? */ #define MEM_BTX_START 0x1000 /* start of BTX memory */ #define MEM_BTX_ESP0 0x1800 /* Supervisor stack */ #define MEM_BTX_BUF 0x1800 /* Scratch buffer stack */ @@ -64,15 +67,20 @@ #define MEM_BTX_TSS 0x1f98 /* TSS */ #define MEM_BTX_MAP 0x2000 /* I/O bit map */ #define MEM_BTX_DIR 0x4000 /* Page directory */ + +/* + * NOTE: page table location is hardwired in /usr/src/usr.sbin/btxld/btx.h + */ #define MEM_BTX_TBL 0x5000 /* Page tables */ + +/* + * NOTE: BOOT2_LOAD_BUF also determines where the btx loader and boot2.bin + * code are loaded, since they are all in the boot2 file. + */ +#define BOOT2_LOAD_BUF 0x8c00 /* boot1 loads boot2 */ #define MEM_BTX_ORG 0x9000 /* base of BTX code */ #define MEM_BTX_ENTRY 0x9010 /* BTX starts execution here */ #define MEM_BTX_USR 0xa000 /* base of BTX client/user memory */ #define MEM_BTX_USR_ARG 0xa100 -#define MEM_BTX_LDR_OFF MEM_PAGE_SIZE /* offset of btx in the loader - -/* - * CDBOOT - */ -#define MEM_BTX_LDR_OFFSET 0x1000 /* Offset of BTX in the loader */ +#define MEM_BTX_LDR_OFF MEM_PAGE_SIZE /* offset of btx in the loader */ diff --git a/sys/boot/pc32/btx/btx/btx.S b/sys/boot/pc32/btx/btx/btx.S index 3ebc0bd79b..0a04d56e69 100644 --- a/sys/boot/pc32/btx/btx/btx.S +++ b/sys/boot/pc32/btx/btx/btx.S @@ -13,7 +13,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/btx/btx/btx.s,v 1.32 2002/10/08 18:19:02 jhb Exp $ - * $DragonFly: src/sys/boot/pc32/btx/btx/btx.S,v 1.5 2004/07/18 23:40:04 dillon Exp $ + * $DragonFly: src/sys/boot/pc32/btx/btx/btx.S,v 1.6 2004/07/19 01:25:00 dillon Exp $ */ #include "../../bootasm.h" @@ -217,10 +217,14 @@ init.8: xorl %ecx,%ecx # Zero */ movb $SEL_TSS,%cl # Set task ltr %cx # register + /* + * XXX We should NOT use BDA_MEM here. Use a fixed location + * instead. + */ movl $MEM_BTX_USR,%edx # User base address movzwl %ss:BDA_MEM,%eax # Get free memory shll $0xa,%eax # To bytes - subl $0x1000,%eax # Less arg space + subl $USR_ARGSPACE,%eax # Less arg space subl %edx,%eax # Less base movb $SEL_UDATA,%cl # User data selector pushl %ecx # Set SS diff --git a/sys/boot/pc32/btx/btxldr/btxldr.S b/sys/boot/pc32/btx/btxldr/btxldr.S index 48d5e57e62..ff8dd86365 100644 --- a/sys/boot/pc32/btx/btxldr/btxldr.S +++ b/sys/boot/pc32/btx/btxldr/btxldr.S @@ -13,7 +13,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/btx/btxldr/Makefile,v 1.17 2004/04/27 19:45:16 ru Exp $ - * $DragonFly: src/sys/boot/pc32/btx/btxldr/btxldr.S,v 1.1 2004/06/25 00:38:38 dillon Exp $ + * $DragonFly: src/sys/boot/pc32/btx/btxldr/btxldr.S,v 1.2 2004/07/19 01:25:01 dillon Exp $ */ /* @@ -21,13 +21,10 @@ * real thing should probably be more flexible, and in C. */ +#include "../../bootasm.h" /* * Memory locations. */ - .set MEM_STUB,0x600 # Real mode stub - .set MEM_ESP,0x1000 # New stack pointer - .set MEM_TBL,0x5000 # BTX page tables - .set MEM_ENTRY,0x9010 # BTX entry point .set MEM_DATA,start+0x1000 # Data segment /* * Segment selectors. @@ -47,12 +44,6 @@ .set SCR_MAT,0x7 # Mode/attribute .set SCR_COL,0x50 # Columns per row .set SCR_ROW,0x19 # Rows per screen -/* - * BIOS Data Area locations. - */ - .set BDA_MEM,0x413 # Free memory - .set BDA_SCR,0x449 # Video mode - .set BDA_POS,0x450 # Cursor position /* * Required by aout gas inadequacy. */ @@ -68,7 +59,7 @@ start: cld # String ops inc movl $m_logo,%esi # Identify call putstr # ourselves movzwl BDA_MEM,%eax # Get base memory - shll $0xa,%eax # in bytes + shll $0xa,%eax # Convert to bytes movl %eax,%ebp # Base of user stack #ifdef BTXLDR_VERBOSE movl $m_mem,%esi # Display @@ -93,7 +84,16 @@ start.1: movl (%ebx),%eax # Get argument and loop start.1 # Till done call putstr # End message #endif - movl $0x48,%ecx # Allocate space + /* + * Arguments: (entry, boothowto, bootdev, 0, 0, 0, bootinfo) + * 0x00, 0x04, 0x08, 0x18 + * + * sizeof(bootinfo) == 0x48 (BOOTINFO_SIZE) + * sizeof arguments == 0x18 (MEM_ARG_SIZE) + * total arguments == 0x60 bytes (USR_ARGOFFSET) + */ + + movl $BOOTINFO_SIZE,%ecx # Allocate space subl %ecx,%ebp # for bootinfo movl 0x18(%esp,1),%esi # Source: bootinfo cmpl $0x0, %esi # If the bootinfo pointer @@ -123,7 +123,7 @@ start_null_bi: movl $0x18,%ecx # Allocate space /* * Set up BTX kernel. */ - movl $MEM_ESP,%esp # Set up new stack + movl $MEM_BTX_ESP,%esp # Set up new stack movl $MEM_DATA,%ebx # Data segment movl $m_vers,%esi # Display BTX call putstr # version message @@ -147,7 +147,7 @@ start_null_bi: movl $0x18,%ecx # Allocate space orl $PAG_SIZ/PAG_ENT-1,%edi # the incl %edi # BTX shll $0x2,%edi # load - addl $MEM_TBL,%edi # address + addl $MEM_BTX_TBL,%edi # address pushl %edi # Save load address movzwl 0xa(%ebx),%ecx # Image size #ifdef BTXLDR_VERBOSE @@ -234,11 +234,11 @@ start.7: call putstr # message #endif movl $start.8,%esi # Real mode stub - movl $MEM_STUB,%edi # Destination + movl $BOOT0_ORIGIN,%edi # Destination movl $start.9-start.8,%ecx # Size rep # Relocate movsb # it - ljmp $SEL_RCODE,$MEM_STUB # To 16-bit code + ljmp $SEL_RCODE,$BOOT0_ORIGIN # To 16-bit code .code16 start.8: xorw %ax,%ax # Data movb $SEL_RDATA,%al # selector @@ -250,7 +250,7 @@ start.8: xorw %ax,%ax # Data movl %cr0,%eax # Switch to decw %ax # real movl %eax,%cr0 # mode - ljmp $0,$MEM_ENTRY # Jump to BTX entry point + ljmp $0,$MEM_BTX_ENTRY # Jump to BTX entry point start.9: .code32 /* diff --git a/sys/boot/pc32/btx/lib/btxcsu.S b/sys/boot/pc32/btx/lib/btxcsu.S index e0914b48c8..862af057e2 100644 --- a/sys/boot/pc32/btx/lib/btxcsu.S +++ b/sys/boot/pc32/btx/lib/btxcsu.S @@ -1,44 +1,44 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * $FreeBSD: src/sys/boot/i386/btx/lib/btxcsu.s,v 1.3 1999/08/28 00:40:07 peter Exp $ + * $DragonFly: src/sys/boot/pc32/btx/lib/btxcsu.S,v 1.4 2004/07/19 01:25:02 dillon Exp $ + */ -# $FreeBSD: src/sys/boot/i386/btx/lib/btxcsu.s,v 1.3 1999/08/28 00:40:07 peter Exp $ -# $DragonFly: src/sys/boot/pc32/btx/lib/btxcsu.S,v 1.3 2003/11/10 06:08:35 dillon Exp $ +/* + * BTX C startup code (ELF). + */ -# -# BTX C startup code (ELF). -# +#include "../../bootasm.h" -# -# Globals. -# + /* + * Globals. + */ .global _start -# -# Constants. -# - .set ARGADJ,0xfa0 # Argument adjustment -# -# Client entry point. -# + + /* + * Client entry point. + */ _start: movl %eax,__base # Set base address - movl %esp,%eax # Set - addl $ARGADJ,%eax # argument - movl %eax,__args # pointer + movl %esp,%eax # Get base of arguments + addl $USR_ARGSPACE-USR_ARGOFFSET,%eax + movl %eax,__args call main # Invoke client main() call exit # Invoke client exit() -# -# Data. -# + + /* + * Data + */ .comm __base,4 # Client base address .comm __args,4 # Client arguments diff --git a/sys/boot/pc32/btx/lib/btxsys.S b/sys/boot/pc32/btx/lib/btxsys.S index ff83f8e736..6f1957a30b 100644 --- a/sys/boot/pc32/btx/lib/btxsys.S +++ b/sys/boot/pc32/btx/lib/btxsys.S @@ -1,41 +1,48 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# - -# $FreeBSD: src/sys/boot/i386/btx/lib/btxsys.s,v 1.2 1999/08/28 00:40:07 peter Exp $ -# $DragonFly: src/sys/boot/pc32/btx/lib/btxsys.S,v 1.3 2003/11/10 06:08:35 dillon Exp $ - -# -# BTX system calls. -# - -# -# Globals. -# +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * $FreeBSD: src/sys/boot/i386/btx/lib/btxsys.s,v 1.2 1999/08/28 00:40:07 peter Exp $ + * $DragonFly: src/sys/boot/pc32/btx/lib/btxsys.S,v 1.4 2004/07/19 01:25:02 dillon Exp $ + */ + +/* + * BTX system calls. + */ + +#include "../../bootasm.h" + + /* + * Globals. + */ .global __exit .global __exec -# -# Constants. -# + + /* + * Constants. + */ .set INT_SYS,0x30 # Interrupt number -# -# System call: exit -# + + /* + * System call: exit + */ __exit: xorl %eax,%eax # BTX system int $INT_SYS # call 0x0 -# -# System call: exec -# + + /* + * System call: exec + */ __exec: movl $0x1,%eax # BTX system int $INT_SYS # call 0x1 + + diff --git a/sys/boot/pc32/btx/lib/btxv86.S b/sys/boot/pc32/btx/lib/btxv86.S index a6e0555eed..03c1a508cb 100644 --- a/sys/boot/pc32/btx/lib/btxv86.S +++ b/sys/boot/pc32/btx/lib/btxv86.S @@ -1,32 +1,36 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * + * $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3 1999/08/28 00:40:08 peter Exp $ + * $DragonFly: src/sys/boot/pc32/btx/lib/btxv86.S,v 1.4 2004/07/19 01:25:02 dillon Exp $ + */ -# $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3 1999/08/28 00:40:08 peter Exp $ -# $DragonFly: src/sys/boot/pc32/btx/lib/btxv86.S,v 1.3 2003/11/10 06:08:35 dillon Exp $ +/* + * BTX V86 interface. + */ -# -# BTX V86 interface. -# +#include "../../bootasm.h" -# -# Globals. -# + /* + * Globals. + */ .global __v86int -# -# Fields in V86 interface structure. -# + + /* + * Fields in V86 interface structure. + */ .set V86_CTL,0x0 # Control flags .set V86_ADDR,0x4 # Int number/address .set V86_ES,0x8 # V86 ES @@ -41,14 +45,16 @@ .set V86_EBP,0x2c # V86 EBP .set V86_ESI,0x30 # V86 ESI .set V86_EDI,0x34 # V86 EDI -# -# Other constants. -# + + /* + * Other constants. + */ .set INT_V86,0x31 # Interrupt number .set SIZ_V86,0x38 # Size of V86 structure -# -# V86 interface function. -# + + /* + * V86 interface function. + */ __v86int: popl __v86ret # Save return address pushl $__v86 # Push pointer call __v86_swap # Load V86 registers @@ -57,9 +63,10 @@ __v86int: popl __v86ret # Save return address addl $0x4,%esp # Discard pointer pushl __v86ret # Restore return address ret # To user -# -# Swap V86 and user registers. -# + + /* + * Swap V86 and user registers. + */ __v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP xchgl %eax,V86_EAX(%ebp) # Swap EAX xchgl %ecx,V86_ECX(%ebp) # Swap ECX @@ -79,8 +86,10 @@ __v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP xchgl %edi,V86_EDI(%ebp) # Swap EDI xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP ret # To caller -# -# V86 interface structure. -# + + /* + * V86 interface structure. + */ .comm __v86,SIZ_V86 .comm __v86ret,4 + -- 2.41.0