MFi386: improve argument passing via btxldr

use related definitions in i386 bootargs.h

Reviewed by:	nyan, jhb
MFC after:	1 month
This commit is contained in:
Andriy Gapon 2012-05-11 09:46:17 +00:00
parent 82242c11a6
commit 006d25ce15
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=235264
9 changed files with 35 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 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

View File

@ -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>

View File

@ -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

View File

@ -4,7 +4,9 @@ PROG= cdboot
STRIP=
BINMODE=${NOBINMODE}
NO_MAN=
SRCS= ${PROG}.s
SRCS= ${PROG}.S
CFLAGS+=-I${.CURDIR}/../../i386/common
ORG= 0x0000

View File

@ -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

View File

@ -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;