From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:01:57 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4F0A61065672; Fri, 29 Jun 2012 10:01:57 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3787D8FC0A; Fri, 29 Jun 2012 10:01:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TA1vgU032703; Fri, 29 Jun 2012 10:01:57 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TA1uBd032693; Fri, 29 Jun 2012 10:01:56 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291001.q5TA1uBd032693@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:01:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237756 - in stable/9/sys/boot/i386: btx/btx btx/btxldr btx/lib common loader zfsboot X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:01:57 -0000 Author: avg Date: Fri Jun 29 10:01:56 2012 New Revision: 237756 URL: http://svn.freebsd.org/changeset/base/237756 Log: MFC r235154,r235158: btxldr: future-proof argument passing from boot1/2-ish to loader Added: stable/9/sys/boot/i386/btx/lib/btxcsu.S - copied unchanged from r235154, head/sys/boot/i386/btx/lib/btxcsu.S stable/9/sys/boot/i386/common/bootargs.h - copied unchanged from r235154, head/sys/boot/i386/common/bootargs.h Deleted: stable/9/sys/boot/i386/btx/lib/btxcsu.s Modified: stable/9/sys/boot/i386/btx/btx/Makefile stable/9/sys/boot/i386/btx/btx/btx.S stable/9/sys/boot/i386/btx/btxldr/Makefile stable/9/sys/boot/i386/btx/btxldr/btxldr.S stable/9/sys/boot/i386/btx/lib/Makefile stable/9/sys/boot/i386/loader/main.c stable/9/sys/boot/i386/zfsboot/zfsboot.c Directory Properties: stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) Modified: stable/9/sys/boot/i386/btx/btx/Makefile ============================================================================== --- stable/9/sys/boot/i386/btx/btx/Makefile Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/btx/Makefile Fri Jun 29 10:01:56 2012 (r237756) @@ -12,6 +12,7 @@ BOOT_BTX_FLAGS=0x0 .endif CFLAGS+=-DBTX_FLAGS=${BOOT_BTX_FLAGS} +CFLAGS+=-I${.CURDIR}/../../common .if defined(BTX_SERIAL) BOOT_COMCONSOLE_PORT?= 0x3f8 Modified: stable/9/sys/boot/i386/btx/btx/btx.S ============================================================================== --- stable/9/sys/boot/i386/btx/btx/btx.S Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/btx/btx.S Fri Jun 29 10:01:56 2012 (r237756) @@ -15,6 +15,8 @@ * $FreeBSD$ */ +#include + /* * Memory layout. */ @@ -205,7 +207,7 @@ init.8: xorl %ecx,%ecx # Zero movl $MEM_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 $ARGSPACE,%eax # Less arg space subl %edx,%eax # Less base movb $SEL_UDATA,%cl # User data selector pushl %ecx # Set SS Modified: stable/9/sys/boot/i386/btx/btxldr/Makefile ============================================================================== --- stable/9/sys/boot/i386/btx/btxldr/Makefile Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/btxldr/Makefile Fri Jun 29 10:01:56 2012 (r237756) @@ -6,6 +6,7 @@ NO_MAN= SRCS= btxldr.S CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS} +CFLAGS+=-I${.CURDIR}/../../common .if defined(BTXLDR_VERBOSE) CFLAGS+=-DBTXLDR_VERBOSE Modified: stable/9/sys/boot/i386/btx/btxldr/btxldr.S ============================================================================== --- stable/9/sys/boot/i386/btx/btxldr/btxldr.S Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/btxldr/btxldr.S Fri Jun 29 10:01:56 2012 (r237756) @@ -15,6 +15,8 @@ * $FreeBSD$ */ +#include + #define RBX_MUTE 0x10 /* -m */ #define OPT_SET(opt) (1 << (opt)) @@ -89,7 +91,7 @@ start: cld # String ops inc 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 @@ -97,24 +99,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: stable/9/sys/boot/i386/btx/lib/Makefile ============================================================================== --- stable/9/sys/boot/i386/btx/lib/Makefile Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/lib/Makefile Fri Jun 29 10:01:56 2012 (r237756) @@ -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}/../../common LDFLAGS=-Wl,-r .include Copied: stable/9/sys/boot/i386/btx/lib/btxcsu.S (from r235154, head/sys/boot/i386/btx/lib/btxcsu.S) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/i386/btx/lib/btxcsu.S Fri Jun 29 10:01:56 2012 (r237756, copy of r235154, head/sys/boot/i386/btx/lib/btxcsu.S) @@ -0,0 +1,49 @@ +# +# 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$ + +#include + +# +# BTX C startup code (ELF). +# + +# +# Globals. +# + .global _start +# +# Client entry point. +# +_start: cld + pushl %eax + movl $_edata,%edi + movl $_end,%ecx + subl %edi, %ecx + xorb %al, %al + rep + stosb + popl __base + 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 Copied: stable/9/sys/boot/i386/common/bootargs.h (from r235154, head/sys/boot/i386/common/bootargs.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/i386/common/bootargs.h Fri Jun 29 10:01:56 2012 (r237756, copy of r235154, head/sys/boot/i386/common/bootargs.h) @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2012 Andriy Gapon + * 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$ + */ + +#ifndef _BOOT_I386_ARGS_H_ +#define _BOOT_I386_ARGS_H_ + +#define KARGS_FLAGS_CD 0x1 +#define KARGS_FLAGS_PXE 0x2 +#define KARGS_FLAGS_ZFS 0x4 +#define KARGS_FLAGS_EXTARG 0x8 /* variably sized extended argument */ + +#define BOOTARGS_SIZE 24 /* sizeof(struct bootargs) */ +#define BA_BOOTFLAGS 8 /* offsetof(struct bootargs, bootflags) */ +#define BA_BOOTINFO 20 /* offsetof(struct bootargs, bootinfo) */ +#define BI_SIZE 48 /* offsetof(struct bootinfo, bi_size) */ + +/* + * We reserve some space above BTX allocated stack for the arguments + * and certain data that could hang off them. Currently only struct bootinfo + * is supported in that category. The bootinfo is placed at the top + * of the arguments area and the actual arguments are placed at ARGOFF offset + * from the top and grow towards the top. Hopefully we have enough space + * for bootinfo and the arguments to not run into each other. + * Arguments area below ARGOFF is reserved for future use. + */ +#define ARGSPACE 0x1000 /* total size of the BTX args area */ +#define ARGOFF 0x800 /* actual args offset within the args area */ +#define ARGADJ (ARGSPACE - ARGOFF) + +#ifndef __ASSEMBLER__ + +struct bootargs +{ + uint32_t howto; + uint32_t bootdev; + uint32_t bootflags; + union { + struct { + uint32_t pxeinfo; + uint32_t reserved; + }; + uint64_t zfspool; + }; + uint32_t bootinfo; + + /* + * If KARGS_FLAGS_EXTARG is set in bootflags, then the above fields + * are followed by a uint32_t field that specifies a size of the + * extended arguments (including the size field). + */ +}; + +#endif /*__ASSEMBLER__*/ + +#endif /* !_BOOT_I386_ARGS_H_ */ Modified: stable/9/sys/boot/i386/loader/main.c ============================================================================== --- stable/9/sys/boot/i386/loader/main.c Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/loader/main.c Fri Jun 29 10:01:56 2012 (r237756) @@ -33,34 +33,24 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include #include #include "bootstrap.h" +#include "common/bootargs.h" #include "libi386/libi386.h" #include "btxv86.h" -#define KARGS_FLAGS_CD 0x1 -#define KARGS_FLAGS_PXE 0x2 -#define KARGS_FLAGS_ZFS 0x4 +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; - union { - struct { - u_int32_t pxeinfo; - u_int32_t res2; - }; - uint64_t zfspool; - }; - u_int32_t bootinfo; -} *kargs; +static struct bootargs *kargs; static u_int32_t initial_howto; static u_int32_t initial_bootdev; Modified: stable/9/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- stable/9/sys/boot/i386/zfsboot/zfsboot.c Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/zfsboot/zfsboot.c Fri Jun 29 10:01:56 2012 (r237756) @@ -41,9 +41,7 @@ __FBSDID("$FreeBSD$"); #include "drv.h" #include "util.h" #include "cons.h" - -/* Hint to loader that we came from ZFS */ -#define KARGS_FLAGS_ZFS 0x4 +#include "bootargs.h" #define PATH_DOTCONFIG "/boot.config" #define PATH_CONFIG "/boot/config"