Module Name: src Committed By: thorpej Date: Wed Feb 17 23:21:47 UTC 2021
Modified Files: src/sys/arch/macppc/macppc: locore.S src/sys/arch/ofppc/ofppc: locore.S Log Message: Document the register state on entry per the OpenFirmware PowerPC CPU bindings. Ensure we save off %r6 and %r7 before calling any other functions. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/arch/macppc/macppc/locore.S cvs rdiff -u -r1.50 -r1.51 src/sys/arch/ofppc/ofppc/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/macppc/macppc/locore.S diff -u src/sys/arch/macppc/macppc/locore.S:1.77 src/sys/arch/macppc/macppc/locore.S:1.78 --- src/sys/arch/macppc/macppc/locore.S:1.77 Sat Feb 13 02:17:02 2021 +++ src/sys/arch/macppc/macppc/locore.S Wed Feb 17 23:21:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.77 2021/02/13 02:17:02 thorpej Exp $ */ +/* $NetBSD: locore.S,v 1.78 2021/02/17 23:21:46 thorpej Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -77,10 +77,23 @@ _C_LABEL(kernel_text): /* * Startup entry. Note, this must be the first thing in the text * segment! + * + * Register state as transfer is passed from OpenFirmware / boot loader: + * + * %r1 Stack provided by OpenFirmware / boot loader + * %r3 Reserved for platform binding (unused here) + * %r4 Reserved for platform binding (unused here) + * %r5 OpenFirmware client entry point + * %r6 Arguments + * %r7 Arguments length */ .text .globl __start __start: + /* Save off arguments that we need preserved. */ + mr %r13,%r6 + mr %r14,%r7 + bl _C_LABEL(ofwinit) /* init OF */ li %r0,0 @@ -89,8 +102,6 @@ __start: #endif isync - mr %r13,%r6 - mr %r14,%r7 bl _C_LABEL(cpu_model_init) /* init oeacpufeat */ /* compute end of kernel memory */ Index: src/sys/arch/ofppc/ofppc/locore.S diff -u src/sys/arch/ofppc/ofppc/locore.S:1.50 src/sys/arch/ofppc/ofppc/locore.S:1.51 --- src/sys/arch/ofppc/ofppc/locore.S:1.50 Sun Jul 15 05:16:43 2018 +++ src/sys/arch/ofppc/ofppc/locore.S Wed Feb 17 23:21:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.50 2018/07/15 05:16:43 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.51 2021/02/17 23:21:47 thorpej Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -75,13 +75,24 @@ _C_LABEL(kernel_text): /* * Startup entry. Note, this must be the first thing in the text * segment! + * + * Register state as transfer is passed from OpenFirmware / boot loader: + * + * %r1 Stack provided by OpenFirmware / boot loader + * %r3 Reserved for platform binding (unused here) + * %r4 Reserved for platform binding (unused here) + * %r5 OpenFirmware client entry point + * %r6 Arguments + * %r7 Arguments length */ .text .globl __start __start: + /* Save off arguments that we need preserved. */ mr %r13,%r6 mr %r14,%r7 - bl _C_LABEL(ofwinit) /* init our OF hooks */ + + bl _C_LABEL(ofwinit) /* init OF */ li %r0,0 mtmsr %r0 /* Disable FPU/MMU/exceptions */