Date: Fri, 11 May 2012 14:05:38 -0400 From: Warner Losh <IMP@bsdimp.com> To: "arm@freebsd.org" <arm@freebsd.org> Subject: Changes to locore.S needing review Message-ID: <D33F04CE-139A-46F0-B73F-AFCAC56F74AD@bsdimp.com>
next in thread | raw e-mail | index | archive | help
--Apple-Mail-3--177430528 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I'd like to get a review on the locore.S part of the changes that I'm = making to support booting from a Linux boot loader directly for the = kernel. My arm assembler knowledge is somewhat weak, so I hope I = haven't botched anything. The changes conditionally save r0, r1 and r2 away for the early boot, = then put them in a structure to pass to board_init(). It also tries to = clean up the register usage a bit so I can save away these values in = registers and I don't have to worry about storing values. Please let me know what you think. Warner --Apple-Mail-3--177430528 Content-Disposition: attachment; filename=1 Content-Type: application/octet-stream; x-unix-mode=0664; name="1" Content-Transfer-Encoding: 7bit Index: arm/locore.S =================================================================== --- arm/locore.S (revision 235278) +++ arm/locore.S (working copy) @@ -37,6 +37,8 @@ #include <machine/asm.h> #include <machine/armreg.h> #include <machine/pte.h> +#include <machine/md_var.h> + __FBSDID("$FreeBSD$"); /* What size should this really be ? It is only used by initarm() */ @@ -61,15 +63,26 @@ .globl physaddr .set physaddr,PHYSADDR -ENTRY_NP(btext) - /* - * On entry: + * On entry for FreeBSD boot ABI: * r0 - metadata pointer or 0 * r1 - if (r0 == 0) then metadata pointer + * initarm gets passed this metadata as arg1 with 0 as arg2. + * On entry for Linux boot ABI: + * r0 - 0 + * r1 - machine type (passed as arg2 to initarm) + * r2 - Pointer to a tagged list or dtb image (phys addr) (passed as arg1 initarm) */ +ENTRY_NP(btext) ASENTRY_NP(_start) +#ifdef LINUX_BOOT_ABI + /* Maybe we should just always do this and let the boards sort it out */ + mov r9, r0 /* 0 or boot mode from boot2 */ + mov r8, r1 /* Save Machine type */ + mov ip, r2 /* Save meta data */ + mov fp, r3 /* Save r3 */ +#else /* Move metadata ptr to r12 (ip) */ mov ip, r0 ldr r0, =0 @@ -77,6 +90,7 @@ bne 1f mov ip, r1 1: +#endif /* Make sure interrupts are disabled. */ mrs r7, cpsr orr r7, r7, #(I32_bit|F32_bit) @@ -91,25 +105,25 @@ */ mrc p15, 0, r2, c1, c0, 0 ands r2, r2, #CPU_CONTROL_MMU_ENABLE - ldreq r8, =PHYSADDR - ldrne r8, =LOADERRAMADDR - cmp r7, r8 + ldreq r6, =PHYSADDR + ldrne r6, =LOADERRAMADDR + cmp r7, r6 bls flash_lower cmp r7, pc bhi from_ram b do_copy flash_lower: - cmp r8, pc + cmp r6, pc bls from_ram do_copy: - ldr r9, =KERNBASE + ldr r7, =KERNBASE adr r1, _start ldr r0, Lreal_start ldr r2, Lend sub r2, r2, r0 - sub r0, r0, r9 - add r0, r0, r8 + sub r0, r0, r7 + add r0, r0, r6 mov r4, r0 bl memcpy ldr r0, Lram_offset @@ -186,7 +200,19 @@ ldr pc, .Lvirt_done virt_done: +#ifdef LINUX_BOOT_ABI + mov r0, sp + adds sp, sp, #20 + str r9, [r0] /* Store r0 from boot loader usually 0 */ + str r8, [r0, #4] /* Store r1 from boot loader machine type */ + str ip, [r0, #8] /* store r2 from boot loader meta data atag or dtb */ + str fp, [r0, #12] /* store r3 from boot loader */ + ld r1, =ARM_FBSDBOOT_MAGIC + str r1, [r0, #16] +#else mov r0, ip /* Load argument: metadata ptr */ + mov r1, #0 /* No machine type passed from boot loader */ +#endif mov fp, #0 /* trace back starts here */ bl _C_LABEL(initarm) /* Off we go */ Index: include/md_var.h =================================================================== --- include/md_var.h (revision 235107) +++ include/md_var.h (working copy) @@ -33,6 +33,7 @@ #ifndef _MACHINE_MD_VAR_H_ #define _MACHINE_MD_VAR_H_ +#ifndef __ASSEMBLER__ extern char sigcode[]; extern int szsigcode; extern uint32_t *vm_page_dump; @@ -69,11 +70,22 @@ }; extern enum cpu_class cpu_class; +struct arm_boot_params { + uintptr_t r0; + uintptr_t r1; + uintptr_t r2; + uintptr_t r3; + uintptr_t magic; +}; + struct dumperinfo; extern int busdma_swi_pending; void busdma_swi(void); void dump_add_page(vm_paddr_t); void dump_drop_page(vm_paddr_t); void minidumpsys(struct dumperinfo *); +#endif +#define ARM_FBSDBOOT_MAGIC 0x46425344 + #endif /* !_MACHINE_MD_VAR_H_ */ --Apple-Mail-3--177430528--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D33F04CE-139A-46F0-B73F-AFCAC56F74AD>