From 6938c9b15656403d78e1ea5a03c4386f4e197153 Mon Sep 17 00:00:00 2001 From: avg Date: Fri, 29 Jun 2012 10:12:27 +0000 Subject: [PATCH] MFC r235264: MFi386: improve argument passing via btxldr git-svn-id: svn://svn.freebsd.org/base/stable/8@237764 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/boot/pc98/btx/btx/Makefile | 1 + sys/boot/pc98/btx/btx/btx.S | 4 +++- sys/boot/pc98/btx/btxldr/Makefile | 1 + sys/boot/pc98/btx/btxldr/btxldr.S | 22 +++++++++++++------- sys/boot/pc98/btx/lib/Makefile | 3 ++- sys/boot/pc98/btx/lib/{btxcsu.s => btxcsu.S} | 6 ++---- sys/boot/pc98/cdboot/Makefile | 4 +++- sys/boot/pc98/cdboot/{cdboot.s => cdboot.S} | 7 ++----- sys/boot/pc98/loader/main.c | 18 +++++++--------- 9 files changed, 35 insertions(+), 31 deletions(-) rename sys/boot/pc98/btx/lib/{btxcsu.s => btxcsu.S} (94%) rename sys/boot/pc98/cdboot/{cdboot.s => cdboot.S} (99%) diff --git a/sys/boot/pc98/btx/btx/Makefile b/sys/boot/pc98/btx/btx/Makefile index 59e380dcd..294971b94 100644 --- a/sys/boot/pc98/btx/btx/Makefile +++ b/sys/boot/pc98/btx/btx/Makefile @@ -12,6 +12,7 @@ BOOT_BTX_FLAGS=0x0 .endif CFLAGS+=-DBTX_FLAGS=${BOOT_BTX_FLAGS} +CFLAGS+=-I${.CURDIR}/../../../i386/common .if defined(BTX_SERIAL) BOOT_COMCONSOLE_PORT?= 0x238 diff --git a/sys/boot/pc98/btx/btx/btx.S b/sys/boot/pc98/btx/btx/btx.S index 95788d4f8..ceed5a69e 100644 --- a/sys/boot/pc98/btx/btx/btx.S +++ b/sys/boot/pc98/btx/btx/btx.S @@ -15,6 +15,8 @@ * $FreeBSD$ */ +#include + /* * Memory layout. */ @@ -205,7 +207,7 @@ init.8: xorl %ecx,%ecx # Zero andl $0x7,%eax incl %eax shll $0x11,%eax # To bytes - subl $0x1000,%eax # Less arg space + subl $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/pc98/btx/btxldr/Makefile b/sys/boot/pc98/btx/btxldr/Makefile index ba7a9938a..ac1208e06 100644 --- a/sys/boot/pc98/btx/btxldr/Makefile +++ b/sys/boot/pc98/btx/btxldr/Makefile @@ -6,6 +6,7 @@ NO_MAN= SRCS= btxldr.S CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS} +CFLAGS+=-I${.CURDIR}/../../../i386/common .if defined(BTXLDR_VERBOSE) CFLAGS+=-DBTXLDR_VERBOSE diff --git a/sys/boot/pc98/btx/btxldr/btxldr.S b/sys/boot/pc98/btx/btxldr/btxldr.S index 2104605b7..683d6c8e6 100644 --- a/sys/boot/pc98/btx/btxldr/btxldr.S +++ b/sys/boot/pc98/btx/btxldr/btxldr.S @@ -20,6 +20,8 @@ * real thing should probably be more flexible, and in C. */ +#include + /* * Memory locations. */ @@ -105,7 +107,7 @@ gdcwait.2: inb $0x60,%al call hexout # stack call putstr # pointer movl $m_args,%esi # Format string - leal 0x4(%esp,1),%ebx # First argument + leal 0x4(%esp),%ebx # First argument movl $0x6,%ecx # Count start.1: movl (%ebx),%eax # Get argument and addl $0x4,%ebx # bump pointer @@ -113,24 +115,28 @@ start.1: movl (%ebx),%eax # Get argument and loop start.1 # Till done call putstr # End message #endif - movl $0x48,%ecx # Allocate space - subl %ecx,%ebp # for bootinfo - movl 0x18(%esp,1),%esi # Source: bootinfo + movl BA_BOOTINFO+4(%esp),%esi # Source: bootinfo cmpl $0x0, %esi # If the bootinfo pointer je start_null_bi # is null, don't copy it + movl BI_SIZE(%esi),%ecx # Allocate space + subl %ecx,%ebp # for bootinfo movl %ebp,%edi # Destination rep # Copy movsb # it - movl %ebp,0x18(%esp,1) # Update pointer + movl %ebp,BA_BOOTINFO+4(%esp) # Update pointer + movl %edi,%ebp # Restore base pointer #ifdef BTXLDR_VERBOSE movl $m_rel_bi,%esi # Display movl %ebp,%eax # bootinfo call hexout # relocation call putstr # message #endif -start_null_bi: movl $0x18,%ecx # Allocate space - subl %ecx,%ebp # for arguments - leal 0x4(%esp,1),%esi # Source +start_null_bi: movl $BOOTARGS_SIZE,%ecx # Fixed size of arguments + testl $KARGS_FLAGS_EXTARG, BA_BOOTFLAGS+4(%esp) # Check for extra data + jz start_fixed # Skip if the flag is not set + addl BOOTARGS_SIZE+4(%esp),%ecx # Add size of variable args +start_fixed: subl $ARGOFF,%ebp # Place args at fixed offset + leal 0x4(%esp),%esi # Source movl %ebp,%edi # Destination rep # Copy movsb # them diff --git a/sys/boot/pc98/btx/lib/Makefile b/sys/boot/pc98/btx/lib/Makefile index 8fab66a54..151fc8fc8 100644 --- a/sys/boot/pc98/btx/lib/Makefile +++ b/sys/boot/pc98/btx/lib/Makefile @@ -3,7 +3,8 @@ PROG= crt0.o INTERNALPROG= NO_MAN= -SRCS= btxcsu.s btxsys.s btxv86.s +SRCS= btxcsu.S btxsys.s btxv86.s +CFLAGS+=-I${.CURDIR}/../../../i386/common LDFLAGS=-Wl,-r .include diff --git a/sys/boot/pc98/btx/lib/btxcsu.s b/sys/boot/pc98/btx/lib/btxcsu.S similarity index 94% rename from sys/boot/pc98/btx/lib/btxcsu.s rename to sys/boot/pc98/btx/lib/btxcsu.S index 6a0065962..8af6ad626 100644 --- a/sys/boot/pc98/btx/lib/btxcsu.s +++ b/sys/boot/pc98/btx/lib/btxcsu.S @@ -19,15 +19,13 @@ # BTX C startup code (ELF). # +#include + # # Globals. # .global _start # -# Constants. -# - .set ARGADJ,0xfa0 # Argument adjustment -# # Client entry point. # _start: cld diff --git a/sys/boot/pc98/cdboot/Makefile b/sys/boot/pc98/cdboot/Makefile index d9e3fb579..0395e6122 100644 --- a/sys/boot/pc98/cdboot/Makefile +++ b/sys/boot/pc98/cdboot/Makefile @@ -4,7 +4,9 @@ PROG= cdboot STRIP= BINMODE=${NOBINMODE} NO_MAN= -SRCS= ${PROG}.s +SRCS= ${PROG}.S + +CFLAGS+=-I${.CURDIR}/../../i386/common ORG= 0x0000 diff --git a/sys/boot/pc98/cdboot/cdboot.s b/sys/boot/pc98/cdboot/cdboot.S similarity index 99% rename from sys/boot/pc98/cdboot/cdboot.s rename to sys/boot/pc98/cdboot/cdboot.S index b6efeef64..a6508e2ff 100644 --- a/sys/boot/pc98/cdboot/cdboot.s +++ b/sys/boot/pc98/cdboot/cdboot.S @@ -30,6 +30,8 @@ # $FreeBSD$ +#include + # # Basically, we first create a set of boot arguments to pass to the loaded # binary. Then we attempt to load /boot/loader from the CD we were booted @@ -82,11 +84,6 @@ .set AOUT_ENTRY,0x14 # entry point .set AOUT_HEADER,MEM_PAGE_SIZE # size of the a.out header # -# Flags for kargs->bootflags -# - .set KARGS_FLAGS_CD,0x1 # flag to indicate booting from - # CD loader -# # Segment selectors. # .set SEL_SDATA,0x8 # Supervisor data diff --git a/sys/boot/pc98/loader/main.c b/sys/boot/pc98/loader/main.c index b54b28c91..bb69f67c3 100644 --- a/sys/boot/pc98/loader/main.c +++ b/sys/boot/pc98/loader/main.c @@ -33,28 +33,24 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include #include "bootstrap.h" +#include "common/bootargs.h" #include "libi386/libi386.h" #include "libpc98/libpc98.h" #include "btxv86.h" -#define KARGS_FLAGS_CD 0x1 -#define KARGS_FLAGS_PXE 0x2 +CTASSERT(sizeof(struct bootargs) == BOOTARGS_SIZE); +CTASSERT(offsetof(struct bootargs, bootinfo) == BA_BOOTINFO); +CTASSERT(offsetof(struct bootargs, bootflags) == BA_BOOTFLAGS); +CTASSERT(offsetof(struct bootinfo, bi_size) == BI_SIZE); /* Arguments passed in from the boot1/boot2 loader */ -static struct -{ - u_int32_t howto; - u_int32_t bootdev; - u_int32_t bootflags; - u_int32_t pxeinfo; - u_int32_t res2; - u_int32_t bootinfo; -} *kargs; +static struct bootargs *kargs; static u_int32_t initial_howto; static u_int32_t initial_bootdev; -- 2.45.0