| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: main.c,v 1.10 2012/02/24 18:45:20 skrll Exp $ */ | | 1 | /* $NetBSD: main.c,v 1.11 2013/06/15 00:41:56 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2003 ITOH Yasufumi. | | 4 | * Copyright (c) 2003 ITOH Yasufumi. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary forms are unlimited. | | 12 | * 2. Redistributions in binary forms are unlimited. |
13 | * | | 13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' | | 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' |
| @@ -31,29 +31,29 @@ | | | @@ -31,29 +31,29 @@ |
31 | #include <sys/exec_elf.h> | | 31 | #include <sys/exec_elf.h> |
32 | #include "readufs.h" | | 32 | #include "readufs.h" |
33 | | | 33 | |
34 | #define STACK_SIZE ((unsigned) (64*1024)) | | 34 | #define STACK_SIZE ((unsigned) (64*1024)) |
35 | #define LOAD_ALIGN ((unsigned) 2048) | | 35 | #define LOAD_ALIGN ((unsigned) 2048) |
36 | | | 36 | |
37 | #define PZ_MEM_BOOT 0x3d0 | | 37 | #define PZ_MEM_BOOT 0x3d0 |
38 | #define DEV_CLASS 0x2c | | 38 | #define DEV_CLASS 0x2c |
39 | #define DEV_CL_MASK 0xf | | 39 | #define DEV_CL_MASK 0xf |
40 | #define DEV_CL_SEQU 0x2 /* sequential record access media */ | | 40 | #define DEV_CL_SEQU 0x2 /* sequential record access media */ |
41 | | | 41 | |
42 | static char *hexstr(char *, unsigned); | | 42 | static char *hexstr(char *, unsigned); |
43 | void ipl_main(unsigned /*interactive*/, unsigned /*sptop*/, unsigned /*psw*/); | | 43 | void ipl_main(unsigned /*interactive*/, unsigned /*sptop*/, unsigned /*psw*/); |
44 | void load_file(const char *, unsigned /*loadadr*/, unsigned /*interactive*/, | | 44 | void load_file(const char *, uintptr_t /*loadadr*/, unsigned /*interactive*/, |
45 | int /*part*/); | | 45 | int /*part*/); |
46 | void load_file_ino(ino32_t, const char *, unsigned /*loadadr*/, | | 46 | void load_file_ino(ino32_t, const char *, uintptr_t /*loadadr*/, |
47 | unsigned /*interactive*/, int /*part*/); | | 47 | unsigned /*interactive*/, int /*part*/); |
48 | | | 48 | |
49 | struct loadinfo { | | 49 | struct loadinfo { |
50 | void *sec_image; | | 50 | void *sec_image; |
51 | unsigned sec_size; | | 51 | unsigned sec_size; |
52 | #if 0 | | 52 | #if 0 |
53 | unsigned sec_pad; | | 53 | unsigned sec_pad; |
54 | #endif | | 54 | #endif |
55 | unsigned entry_offset; | | 55 | unsigned entry_offset; |
56 | }; | | 56 | }; |
57 | static inline void xi_elf32(struct loadinfo *, Elf32_Ehdr *); | | 57 | static inline void xi_elf32(struct loadinfo *, Elf32_Ehdr *); |
58 | static inline void xi_elf64(struct loadinfo *, Elf64_Ehdr *); | | 58 | static inline void xi_elf64(struct loadinfo *, Elf64_Ehdr *); |
59 | int xi_load(struct loadinfo *, void *); | | 59 | int xi_load(struct loadinfo *, void *); |
| @@ -174,27 +174,27 @@ hexstr(char *buf, unsigned val) | | | @@ -174,27 +174,27 @@ hexstr(char *buf, unsigned val) |
174 | return buf; | | 174 | return buf; |
175 | } | | 175 | } |
176 | | | 176 | |
177 | void | | 177 | void |
178 | ipl_main(unsigned interactive, unsigned sptop, unsigned psw) | | 178 | ipl_main(unsigned interactive, unsigned sptop, unsigned psw) |
179 | /* interactive: parameters from PDC */ | | 179 | /* interactive: parameters from PDC */ |
180 | /* sptop: value of sp on function entry */ | | 180 | /* sptop: value of sp on function entry */ |
181 | /* psw: PSW on startup */ | | 181 | /* psw: PSW on startup */ |
182 | { | | 182 | { |
183 | char buf[32]; | | 183 | char buf[32]; |
184 | int part = 0; /* default partition "a" */ | | 184 | int part = 0; /* default partition "a" */ |
185 | unsigned secsz, partoff, partsz; | | 185 | unsigned secsz, partoff, partsz; |
186 | int c, c1; | | 186 | int c, c1; |
187 | unsigned loadadr; | | 187 | uintptr_t loadadr; |
188 | | | 188 | |
189 | #if 0 | | 189 | #if 0 |
190 | print(hexstr(buf, interactive)); | | 190 | print(hexstr(buf, interactive)); |
191 | print(str_crlf); | | 191 | print(str_crlf); |
192 | print(hexstr(buf, sptop)); | | 192 | print(hexstr(buf, sptop)); |
193 | print(str_crlf); | | 193 | print(str_crlf); |
194 | print(hexstr(buf, psw)); | | 194 | print(hexstr(buf, psw)); |
195 | print(str_crlf); | | 195 | print(str_crlf); |
196 | #endif | | 196 | #endif |
197 | | | 197 | |
198 | print(hexstr(buf, (psw & 0x08000000) ? (unsigned) 0x64 : 0x32)); | | 198 | print(hexstr(buf, (psw & 0x08000000) ? (unsigned) 0x64 : 0x32)); |
199 | print(str_bit_firmware); /* "bit firmware\r\n" */ | | 199 | print(str_bit_firmware); /* "bit firmware\r\n" */ |
200 | | | 200 | |
| @@ -284,38 +284,38 @@ ipl_main(unsigned interactive, unsigned | | | @@ -284,38 +284,38 @@ ipl_main(unsigned interactive, unsigned |
284 | } | | 284 | } |
285 | str_filesystem[12] = (ufs_info.fstype == UFSTYPE_FFS) ? 'F' : 'L'; | | 285 | str_filesystem[12] = (ufs_info.fstype == UFSTYPE_FFS) ? 'F' : 'L'; |
286 | print(str_filesystem); /* "filesystem: _FS\r\n" */ | | 286 | print(str_filesystem); /* "filesystem: _FS\r\n" */ |
287 | | | 287 | |
288 | loadadr = (sptop + STACK_SIZE + LOAD_ALIGN - 1) & (-LOAD_ALIGN); | | 288 | loadadr = (sptop + STACK_SIZE + LOAD_ALIGN - 1) & (-LOAD_ALIGN); |
289 | load_file(str_boot1, loadadr, interactive, part); /* "boot.hp700" */ | | 289 | load_file(str_boot1, loadadr, interactive, part); /* "boot.hp700" */ |
290 | load_file(str_boot2, loadadr, interactive, part); /* "boot" */ | | 290 | load_file(str_boot2, loadadr, interactive, part); /* "boot" */ |
291 | load_file(str_boot3, loadadr, interactive, part); /* "usr/mdec/boot" */ | | 291 | load_file(str_boot3, loadadr, interactive, part); /* "usr/mdec/boot" */ |
292 | | | 292 | |
293 | print(str_noboot); /* "no secondary boot found\r\n" */ | | 293 | print(str_noboot); /* "no secondary boot found\r\n" */ |
294 | } | | 294 | } |
295 | | | 295 | |
296 | void | | 296 | void |
297 | load_file(const char *path, unsigned loadadr, unsigned interactive, int part) | | 297 | load_file(const char *path, uintptr_t loadadr, unsigned interactive, int part) |
298 | { | | 298 | { |
299 | | | 299 | |
300 | /* look-up the file */ | | 300 | /* look-up the file */ |
301 | print(str_lookup); /* "looking up " */ | | 301 | print(str_lookup); /* "looking up " */ |
302 | print(path); | | 302 | print(path); |
303 | print(str_crlf); | | 303 | print(str_crlf); |
304 | load_file_ino(ufs_lookup_path(path), path, loadadr, interactive, part); | | 304 | load_file_ino(ufs_lookup_path(path), path, loadadr, interactive, part); |
305 | } | | 305 | } |
306 | | | 306 | |
307 | void | | 307 | void |
308 | load_file_ino(ino32_t ino, const char *fn, unsigned loadadr, unsigned interactive, int part) | | 308 | load_file_ino(ino32_t ino, const char *fn, uintptr_t loadadr, unsigned interactive, int part) |
309 | /* fn: for message only */ | | 309 | /* fn: for message only */ |
310 | { | | 310 | { |
311 | union ufs_dinode dinode; | | 311 | union ufs_dinode dinode; |
312 | size_t sz; | | 312 | size_t sz; |
313 | struct loadinfo inf; | | 313 | struct loadinfo inf; |
314 | char buf[32]; | | 314 | char buf[32]; |
315 | | | 315 | |
316 | if (ino == 0 || ufs_get_inode(ino, &dinode)) | | 316 | if (ino == 0 || ufs_get_inode(ino, &dinode)) |
317 | return; /* not found */ | | 317 | return; /* not found */ |
318 | | | 318 | |
319 | print(str_loading); /* "loading " */ | | 319 | print(str_loading); /* "loading " */ |
320 | print(fn); | | 320 | print(fn); |
321 | print(str_at); /* " at 0x" */ | | 321 | print(str_at); /* " at 0x" */ |