diff options
author | Geoff Levand <geoffrey.levand@am.sony.com> | 2008-03-27 16:41:45 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-04-01 05:43:07 -0400 |
commit | 5761eaa3a5ae3c7ea796add73b86176b7c963cca (patch) | |
tree | 8b2b5f292059738216202b4b5480cdc02bd925d0 /arch/powerpc/boot | |
parent | 23afcb4e0061c591776a3350db89512d085397c2 (diff) |
[POWERPC] PS3: Bootwrapper improvements
Improve the debugging support of the PS3 bootwraper code:
o Increase the size of the PS3 bootwrapper overlay from 256 to 512 bytes to
allow for more debugging code in the overlay.
o Use the dot symbol to set the size of __system_reset_overlay. The
assembler will then emit an error if the overlay code is too big.
o Remove some unused instructions.
o Update the text describing the PS3 bootwrapper overlay.
o Add a check for null pointer writes.
o Change hcall return value from s64.
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot')
-rw-r--r-- | arch/powerpc/boot/ps3-head.S | 25 | ||||
-rw-r--r-- | arch/powerpc/boot/ps3.c | 23 | ||||
-rwxr-xr-x | arch/powerpc/boot/wrapper | 21 |
3 files changed, 42 insertions, 27 deletions
diff --git a/arch/powerpc/boot/ps3-head.S b/arch/powerpc/boot/ps3-head.S index a55c2735f759..b6fcbaf5027b 100644 --- a/arch/powerpc/boot/ps3-head.S +++ b/arch/powerpc/boot/ps3-head.S | |||
@@ -27,8 +27,9 @@ | |||
27 | /* | 27 | /* |
28 | * __system_reset_overlay - The PS3 first stage entry. | 28 | * __system_reset_overlay - The PS3 first stage entry. |
29 | * | 29 | * |
30 | * The bootwraper build script copies the 0x100 bytes at symbol | 30 | * The bootwraper build script copies the 512 bytes at symbol |
31 | * __system_reset_overlay to offset 0x100 of the rom image. | 31 | * __system_reset_overlay to offset 0x100 of the rom image. This symbol |
32 | * must occupy 512 or less bytes. | ||
32 | * | 33 | * |
33 | * The PS3 has a single processor with two threads. | 34 | * The PS3 has a single processor with two threads. |
34 | */ | 35 | */ |
@@ -47,8 +48,6 @@ __system_reset_overlay: | |||
47 | 48 | ||
48 | mfspr r3, 0x88 | 49 | mfspr r3, 0x88 |
49 | cntlzw. r3, r3 | 50 | cntlzw. r3, r3 |
50 | li r4, 0 | ||
51 | li r5, 0 | ||
52 | beq 1f | 51 | beq 1f |
53 | 52 | ||
54 | /* Secondary goes to __secondary_hold in kernel. */ | 53 | /* Secondary goes to __secondary_hold in kernel. */ |
@@ -57,8 +56,14 @@ __system_reset_overlay: | |||
57 | mtctr r4 | 56 | mtctr r4 |
58 | bctr | 57 | bctr |
59 | 58 | ||
60 | /* Primary delays then goes to _zimage_start in wrapper. */ | ||
61 | 1: | 59 | 1: |
60 | /* Save the value at addr zero for a null pointer write check later. */ | ||
61 | |||
62 | li r4, 0 | ||
63 | lwz r3, 0(r4) | ||
64 | |||
65 | /* Primary delays then goes to _zimage_start in wrapper. */ | ||
66 | |||
62 | or 31, 31, 31 /* db16cyc */ | 67 | or 31, 31, 31 /* db16cyc */ |
63 | or 31, 31, 31 /* db16cyc */ | 68 | or 31, 31, 31 /* db16cyc */ |
64 | 69 | ||
@@ -67,16 +72,18 @@ __system_reset_overlay: | |||
67 | mtctr r4 | 72 | mtctr r4 |
68 | bctr | 73 | bctr |
69 | 74 | ||
75 | . = __system_reset_overlay + 512 | ||
76 | |||
70 | /* | 77 | /* |
71 | * __system_reset_kernel - Place holder for the kernel reset vector. | 78 | * __system_reset_kernel - Place holder for the kernel reset vector. |
72 | * | 79 | * |
73 | * The bootwrapper build script copies 0x100 bytes from offset 0x100 | 80 | * The bootwrapper build script copies 512 bytes from offset 0x100 |
74 | * of the rom image to the symbol __system_reset_kernel. At runtime | 81 | * of the rom image to the symbol __system_reset_kernel. At runtime |
75 | * the bootwrapper program copies the 0x100 bytes at __system_reset_kernel | 82 | * the bootwrapper program copies the 512 bytes at __system_reset_kernel |
76 | * to ram address 0x100. This symbol must occupy 0x100 bytes. | 83 | * to ram address 0x100. This symbol must occupy 512 bytes. |
77 | */ | 84 | */ |
78 | 85 | ||
79 | .globl __system_reset_kernel | 86 | .globl __system_reset_kernel |
80 | __system_reset_kernel: | 87 | __system_reset_kernel: |
81 | 88 | ||
82 | . = __system_reset_kernel + 0x100 | 89 | . = __system_reset_kernel + 512 |
diff --git a/arch/powerpc/boot/ps3.c b/arch/powerpc/boot/ps3.c index 3b0ac4d006ec..9954d98871d0 100644 --- a/arch/powerpc/boot/ps3.c +++ b/arch/powerpc/boot/ps3.c | |||
@@ -27,10 +27,10 @@ | |||
27 | #include "page.h" | 27 | #include "page.h" |
28 | #include "ops.h" | 28 | #include "ops.h" |
29 | 29 | ||
30 | extern s64 lv1_panic(u64 in_1); | 30 | extern int lv1_panic(u64 in_1); |
31 | extern s64 lv1_get_logical_partition_id(u64 *out_1); | 31 | extern int lv1_get_logical_partition_id(u64 *out_1); |
32 | extern s64 lv1_get_logical_ppe_id(u64 *out_1); | 32 | extern int lv1_get_logical_ppe_id(u64 *out_1); |
33 | extern s64 lv1_get_repository_node_value(u64 in_1, u64 in_2, u64 in_3, | 33 | extern int lv1_get_repository_node_value(u64 in_1, u64 in_2, u64 in_3, |
34 | u64 in_4, u64 in_5, u64 *out_1, u64 *out_2); | 34 | u64 in_4, u64 in_5, u64 *out_1, u64 *out_2); |
35 | 35 | ||
36 | #ifdef DEBUG | 36 | #ifdef DEBUG |
@@ -46,6 +46,7 @@ BSS_STACK(4096); | |||
46 | * edit the command line passed to vmlinux (by setting /chosen/bootargs). | 46 | * edit the command line passed to vmlinux (by setting /chosen/bootargs). |
47 | * The buffer is put in it's own section so that tools may locate it easier. | 47 | * The buffer is put in it's own section so that tools may locate it easier. |
48 | */ | 48 | */ |
49 | |||
49 | static char cmdline[COMMAND_LINE_SIZE] | 50 | static char cmdline[COMMAND_LINE_SIZE] |
50 | __attribute__((__section__("__builtin_cmdline"))); | 51 | __attribute__((__section__("__builtin_cmdline"))); |
51 | 52 | ||
@@ -75,7 +76,7 @@ static void ps3_exit(void) | |||
75 | 76 | ||
76 | static int ps3_repository_read_rm_size(u64 *rm_size) | 77 | static int ps3_repository_read_rm_size(u64 *rm_size) |
77 | { | 78 | { |
78 | s64 result; | 79 | int result; |
79 | u64 lpar_id; | 80 | u64 lpar_id; |
80 | u64 ppe_id; | 81 | u64 ppe_id; |
81 | u64 v2; | 82 | u64 v2; |
@@ -114,16 +115,17 @@ void ps3_copy_vectors(void) | |||
114 | { | 115 | { |
115 | extern char __system_reset_kernel[]; | 116 | extern char __system_reset_kernel[]; |
116 | 117 | ||
117 | memcpy((void *)0x100, __system_reset_kernel, 0x100); | 118 | memcpy((void *)0x100, __system_reset_kernel, 512); |
118 | flush_cache((void *)0x100, 0x100); | 119 | flush_cache((void *)0x100, 512); |
119 | } | 120 | } |
120 | 121 | ||
121 | void platform_init(void) | 122 | void platform_init(unsigned long null_check) |
122 | { | 123 | { |
123 | const u32 heapsize = 0x1000000 - (u32)_end; /* 16MiB */ | 124 | const u32 heapsize = 0x1000000 - (u32)_end; /* 16MiB */ |
124 | void *chosen; | 125 | void *chosen; |
125 | unsigned long ft_addr; | 126 | unsigned long ft_addr; |
126 | u64 rm_size; | 127 | u64 rm_size; |
128 | unsigned long val; | ||
127 | 129 | ||
128 | console_ops.write = ps3_console_write; | 130 | console_ops.write = ps3_console_write; |
129 | platform_ops.exit = ps3_exit; | 131 | platform_ops.exit = ps3_exit; |
@@ -151,6 +153,11 @@ void platform_init(void) | |||
151 | 153 | ||
152 | printf(" flat tree at 0x%lx\n\r", ft_addr); | 154 | printf(" flat tree at 0x%lx\n\r", ft_addr); |
153 | 155 | ||
156 | val = *(unsigned long *)0; | ||
157 | |||
158 | if (val != null_check) | ||
159 | printf("null check failed: %lx != %lx\n\r", val, null_check); | ||
160 | |||
154 | ((kernel_entry_t)0)(ft_addr, 0, NULL); | 161 | ((kernel_entry_t)0)(ft_addr, 0, NULL); |
155 | 162 | ||
156 | ps3_exit(); | 163 | ps3_exit(); |
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 03b474bfe747..087e120e4904 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper | |||
@@ -298,15 +298,16 @@ treeboot*) | |||
298 | exit 0 | 298 | exit 0 |
299 | ;; | 299 | ;; |
300 | ps3) | 300 | ps3) |
301 | # The ps3's loader supports loading gzipped binary images from flash | 301 | # The ps3's loader supports loading a gzipped binary image from flash |
302 | # rom to addr zero. The loader enters the image at addr 0x100. A | 302 | # rom to ram addr zero. The loader then enters the system reset |
303 | # bootwrapper overlay is use to arrange for the kernel to be loaded | 303 | # vector at addr 0x100. A bootwrapper overlay is used to arrange for |
304 | # to addr zero and to have a suitable bootwrapper entry at 0x100. | 304 | # a binary image of the kernel to be at addr zero, and yet have a |
305 | # To construct the rom image, 0x100 bytes from offset 0x100 in the | 305 | # suitable bootwrapper entry at 0x100. To construct the final rom |
306 | # kernel is copied to the bootwrapper symbol __system_reset_kernel. | 306 | # image 512 bytes from offset 0x100 is copied to the bootwrapper |
307 | # The 0x100 bytes at the bootwrapper symbol __system_reset_overlay is | 307 | # place holder at symbol __system_reset_kernel. The 512 bytes of the |
308 | # then copied to offset 0x100. At runtime the bootwrapper program | 308 | # bootwrapper entry code at symbol __system_reset_overlay is then |
309 | # copies the 0x100 bytes at __system_reset_kernel to addr 0x100. | 309 | # copied to offset 0x100. At runtime the bootwrapper program copies |
310 | # the data at __system_reset_kernel back to addr 0x100. | ||
310 | 311 | ||
311 | system_reset_overlay=0x`${CROSS}nm "$ofile" \ | 312 | system_reset_overlay=0x`${CROSS}nm "$ofile" \ |
312 | | grep ' __system_reset_overlay$' \ | 313 | | grep ' __system_reset_overlay$' \ |
@@ -317,7 +318,7 @@ ps3) | |||
317 | | cut -d' ' -f1` | 318 | | cut -d' ' -f1` |
318 | system_reset_kernel=`printf "%d" $system_reset_kernel` | 319 | system_reset_kernel=`printf "%d" $system_reset_kernel` |
319 | overlay_dest="256" | 320 | overlay_dest="256" |
320 | overlay_size="256" | 321 | overlay_size="512" |
321 | 322 | ||
322 | ${CROSS}objcopy -O binary "$ofile" "$ofile.bin" | 323 | ${CROSS}objcopy -O binary "$ofile" "$ofile.bin" |
323 | 324 | ||