svn commit: r235264 - in head/sys/boot/pc98: btx/btx btx/btxldr btx/lib cdboot loader

Andriy Gapon avg at FreeBSD.org
Fri May 11 09:46:17 UTC 2012


Author: avg
Date: Fri May 11 09:46:17 2012
New Revision: 235264
URL: http://svn.freebsd.org/changeset/base/235264

Log:
  MFi386: improve argument passing via btxldr
  
  use related definitions in i386 bootargs.h
  
  Reviewed by:	nyan, jhb
  MFC after:	1 month

Added:
  head/sys/boot/pc98/btx/lib/btxcsu.S
     - copied, changed from r235217, head/sys/boot/pc98/btx/lib/btxcsu.s
  head/sys/boot/pc98/cdboot/cdboot.S
     - copied, changed from r235152, head/sys/boot/pc98/cdboot/cdboot.s
Deleted:
  head/sys/boot/pc98/btx/lib/btxcsu.s
  head/sys/boot/pc98/cdboot/cdboot.s
Modified:
  head/sys/boot/pc98/btx/btx/Makefile
  head/sys/boot/pc98/btx/btx/btx.S
  head/sys/boot/pc98/btx/btxldr/Makefile
  head/sys/boot/pc98/btx/btxldr/btxldr.S
  head/sys/boot/pc98/btx/lib/Makefile
  head/sys/boot/pc98/cdboot/Makefile
  head/sys/boot/pc98/loader/main.c

Modified: head/sys/boot/pc98/btx/btx/Makefile
==============================================================================
--- head/sys/boot/pc98/btx/btx/Makefile	Fri May 11 09:34:39 2012	(r235263)
+++ head/sys/boot/pc98/btx/btx/Makefile	Fri May 11 09:46:17 2012	(r235264)
@@ -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

Modified: head/sys/boot/pc98/btx/btx/btx.S
==============================================================================
--- head/sys/boot/pc98/btx/btx/btx.S	Fri May 11 09:34:39 2012	(r235263)
+++ head/sys/boot/pc98/btx/btx/btx.S	Fri May 11 09:46:17 2012	(r235264)
@@ -15,6 +15,8 @@
  * $FreeBSD$
  */
 
+#include <bootargs.h>
+
 /*
  * 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

Modified: head/sys/boot/pc98/btx/btxldr/Makefile
==============================================================================
--- head/sys/boot/pc98/btx/btxldr/Makefile	Fri May 11 09:34:39 2012	(r235263)
+++ head/sys/boot/pc98/btx/btxldr/Makefile	Fri May 11 09:46:17 2012	(r235264)
@@ -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

Modified: head/sys/boot/pc98/btx/btxldr/btxldr.S
==============================================================================
--- head/sys/boot/pc98/btx/btxldr/btxldr.S	Fri May 11 09:34:39 2012	(r235263)
+++ head/sys/boot/pc98/btx/btxldr/btxldr.S	Fri May 11 09:46:17 2012	(r235264)
@@ -20,6 +20,8 @@
  * real thing should probably be more flexible, and in C.
  */
 
+#include <bootargs.h>
+
 /*
  * 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 argumen
 		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

Modified: head/sys/boot/pc98/btx/lib/Makefile
==============================================================================
--- head/sys/boot/pc98/btx/lib/Makefile	Fri May 11 09:34:39 2012	(r235263)
+++ head/sys/boot/pc98/btx/lib/Makefile	Fri May 11 09:46:17 2012	(r235264)
@@ -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 <bsd.prog.mk>

Copied and modified: head/sys/boot/pc98/btx/lib/btxcsu.S (from r235217, head/sys/boot/pc98/btx/lib/btxcsu.s)
==============================================================================
--- head/sys/boot/pc98/btx/lib/btxcsu.s	Thu May 10 09:10:31 2012	(r235217, copy source)
+++ head/sys/boot/pc98/btx/lib/btxcsu.S	Fri May 11 09:46:17 2012	(r235264)
@@ -19,15 +19,13 @@
 # BTX C startup code (ELF).
 #
 
+#include <bootargs.h>
+
 #
 # Globals.
 #
 		.global _start
 #
-# Constants.
-#
-		.set ARGADJ,0xfa0		# Argument adjustment
-#
 # Client entry point.
 #
 _start: 	cld

Modified: head/sys/boot/pc98/cdboot/Makefile
==============================================================================
--- head/sys/boot/pc98/cdboot/Makefile	Fri May 11 09:34:39 2012	(r235263)
+++ head/sys/boot/pc98/cdboot/Makefile	Fri May 11 09:46:17 2012	(r235264)
@@ -4,7 +4,9 @@ PROG=	cdboot
 STRIP=
 BINMODE=${NOBINMODE}
 NO_MAN=
-SRCS=	${PROG}.s
+SRCS=	${PROG}.S
+
+CFLAGS+=-I${.CURDIR}/../../i386/common
 
 ORG=	0x0000
 

Copied and modified: head/sys/boot/pc98/cdboot/cdboot.S (from r235152, head/sys/boot/pc98/cdboot/cdboot.s)
==============================================================================
--- head/sys/boot/pc98/cdboot/cdboot.s	Wed May  9 04:54:50 2012	(r235152, copy source)
+++ head/sys/boot/pc98/cdboot/cdboot.S	Fri May 11 09:46:17 2012	(r235264)
@@ -30,6 +30,8 @@
 
 # $FreeBSD$
 
+#include <bootargs.h>
+
 #
 # 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

Modified: head/sys/boot/pc98/loader/main.c
==============================================================================
--- head/sys/boot/pc98/loader/main.c	Fri May 11 09:34:39 2012	(r235263)
+++ head/sys/boot/pc98/loader/main.c	Fri May 11 09:46:17 2012	(r235264)
@@ -33,29 +33,25 @@ __FBSDID("$FreeBSD$");
  */
 
 #include <stand.h>
+#include <stddef.h>
 #include <string.h>
 #include <machine/bootinfo.h>
 #include <sys/param.h>
 #include <sys/reboot.h>
 
 #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;


More information about the svn-src-all mailing list