| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: bootmain.c,v 1.1 2012/03/20 13:01:32 minoura Exp $ */ | | 1 | /* $NetBSD: bootmain.c,v 1.2 2012/11/17 15:59:28 tsutsui Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1993, 1994 Takumi Nakamura. | | 4 | * Copyright (c) 1993, 1994 Takumi Nakamura. |
5 | * Copyright (c) 1999, 2000 Itoh Yasufumi. | | 5 | * Copyright (c) 1999, 2000 Itoh Yasufumi. |
6 | * Copyright (c) 2001 Minoura Makoto. | | 6 | * Copyright (c) 2001 Minoura Makoto. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -33,64 +33,63 @@ | | | @@ -33,64 +33,63 @@ |
33 | * SUCH DAMAGE. | | 33 | * SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/types.h> | | 37 | #include <sys/types.h> |
38 | #include <machine/bootinfo.h> | | 38 | #include <machine/bootinfo.h> |
39 | #include <lib/libsa/stand.h> | | 39 | #include <lib/libsa/stand.h> |
40 | #include <lib/libsa/loadfile.h> | | 40 | #include <lib/libsa/loadfile.h> |
41 | | | 41 | |
42 | #include "libx68k.h" | | 42 | #include "libx68k.h" |
43 | #include "iocs.h" | | 43 | #include "iocs.h" |
44 | #include "exec_image.h" | | 44 | #include "exec_image.h" |
45 | | | 45 | |
46 | #define EXSCSI_BDID ((void*) 0x00ea0001) | | 46 | #define EXSCSI_BDID ((void *)0x00ea0001) |
47 | | | 47 | |
48 | /* boot_cd9660.S */ | | 48 | /* boot.S */ |
49 | extern int badbaddr __P((volatile void *adr)); | | 49 | extern int badbaddr(volatile void *); |
50 | extern unsigned int ID; /* target SCSI ID */ | | 50 | extern unsigned int ID; /* target SCSI ID */ |
51 | extern unsigned int BOOT_INFO; /* result of IOCS(__BOOTINF) */ | | 51 | extern unsigned int BOOT_INFO; /* result of IOCS(__BOOTINF) */ |
52 | | | 52 | |
53 | /* for debug */ | | 53 | /* for debug */ |
54 | unsigned int startregs[16]; | | 54 | unsigned int startregs[16]; |
55 | | | 55 | |
56 | static int get_scsi_host_adapter (char *); | | 56 | static int get_scsi_host_adapter(char *); |
57 | void bootmain (void) __attribute__ ((__noreturn__)); | | 57 | void bootmain(void) __attribute__ ((__noreturn__)); |
58 | | | 58 | |
59 | /* | | 59 | /* |
60 | * Check the type of SCSI interface | | 60 | * Check the type of SCSI interface |
61 | */ | | 61 | */ |
62 | static int | | 62 | static int |
63 | get_scsi_host_adapter(devstr) | | 63 | get_scsi_host_adapter(char *devstr) |
64 | char *devstr; | | | |
65 | { | | 64 | { |
66 | char *bootrom; | | 65 | uint8_t *bootrom; |
67 | int ha; | | 66 | int ha; |
68 | | | 67 | |
69 | *(int *)devstr = '/' << 24 | 's' << 16 | 'p' << 8 | 'c'; | | 68 | *(uint32_t *)(devstr + 0) = '/' << 24 | 's' << 16 | 'p' << 8 | 'c'; |
70 | *(int *)(devstr + 4) = '@' << 24 | '0' << 16 | '/' << 8 | 'c'; | | 69 | *(uint32_t *)(devstr + 4) = '@' << 24 | '0' << 16 | '/' << 8 | 'c'; |
71 | *(int *)(devstr + 8) = 'd' << 24 | '@' << 16 | '0' << 8 | ','; | | 70 | *(uint32_t *)(devstr + 8) = 'd' << 24 | '@' << 16 | '0' << 8 | ','; |
72 | *(int *)(devstr + 12) = '0' << 24 | ':' << 16 | 'a' << 8 | '\0'; | | 71 | *(uint32_t *)(devstr + 12) = '0' << 24 | ':' << 16 | 'a' << 8 | '\0'; |
73 | | | 72 | |
74 | bootrom = (char *) (BOOT_INFO & 0x00ffffe0); | | 73 | bootrom = (uint8_t *)(BOOT_INFO & 0x00ffffe0); |
75 | /* | | 74 | /* |
76 | * bootrom+0x24 "SCSIIN" ... Internal SCSI (spc@0) | | 75 | * bootrom+0x24 "SCSIIN" ... Internal SCSI (spc@0) |
77 | * "SCSIEX" ... External SCSI (spc@1 or mha@0) | | 76 | * "SCSIEX" ... External SCSI (spc@1 or mha@0) |
78 | */ | | 77 | */ |
79 | if (*(u_short *)(bootrom + 0x24 + 4) == 0x494e) { /* "IN" */ | | 78 | if (*(uint16_t *)(bootrom + 0x24 + 4) == 0x494e) { /* "IN" */ |
80 | ha = (X68K_BOOT_SCSIIF_SPC << 4) | 0; | | 79 | ha = (X68K_BOOT_SCSIIF_SPC << 4) | 0; |
81 | } else if (badbaddr(EXSCSI_BDID)) { | | 80 | } else if (badbaddr(EXSCSI_BDID)) { |
82 | ha = (X68K_BOOT_SCSIIF_MHA << 4) | 0; | | 81 | ha = (X68K_BOOT_SCSIIF_MHA << 4) | 0; |
83 | *(int *)devstr = '/' << 24 | 'm' << 16 | 'h' << 8 | 'a'; | | 82 | *(uint32_t *)devstr = '/' << 24 | 'm' << 16 | 'h' << 8 | 'a'; |
84 | } else { | | 83 | } else { |
85 | ha = (X68K_BOOT_SCSIIF_SPC << 4) | 1; | | 84 | ha = (X68K_BOOT_SCSIIF_SPC << 4) | 1; |
86 | devstr[5] = '1'; | | 85 | devstr[5] = '1'; |
87 | } | | 86 | } |
88 | | | 87 | |
89 | return ha; | | 88 | return ha; |
90 | } | | 89 | } |
91 | | | 90 | |
92 | extern const char bootprog_name[], bootprog_rev[]; | | 91 | extern const char bootprog_name[], bootprog_rev[]; |
93 | | | 92 | |
94 | void | | 93 | void |
95 | bootmain(void) | | 94 | bootmain(void) |
96 | { | | 95 | { |
| @@ -117,19 +116,19 @@ bootmain(void) | | | @@ -117,19 +116,19 @@ bootmain(void) |
117 | fd = loadfile("boot", marks, LOAD_TEXT|LOAD_DATA|LOAD_BSS); | | 116 | fd = loadfile("boot", marks, LOAD_TEXT|LOAD_DATA|LOAD_BSS); |
118 | if (fd >= 0) { | | 117 | if (fd >= 0) { |
119 | close(fd); | | 118 | close(fd); |
120 | exec_image(BOOT_TEXTADDR, /* image loaded at */ | | 119 | exec_image(BOOT_TEXTADDR, /* image loaded at */ |
121 | BOOT_TEXTADDR, /* image executed at */ | | 120 | BOOT_TEXTADDR, /* image executed at */ |
122 | BOOT_TEXTADDR, /* XXX: entry point */ | | 121 | BOOT_TEXTADDR, /* XXX: entry point */ |
123 | 0, /* XXX: image size */ | | 122 | 0, /* XXX: image size */ |
124 | bootdev, 0); /* arguments */ | | 123 | bootdev, 0); /* arguments */ |
125 | } | | 124 | } |
126 | IOCS_B_PRINT("can't load the secondary bootstrap."); | | 125 | IOCS_B_PRINT("can't load the secondary bootstrap."); |
127 | exit(0); | | 126 | exit(0); |
128 | } | | 127 | } |
129 | | | 128 | |
130 | extern int xxboot(struct open_file *); | | | |
131 | int | | 129 | int |
132 | devopen(struct open_file *f, const char *fname, char **file) | | 130 | devopen(struct open_file *f, const char *fname, char **file) |
133 | { | | 131 | { |
| | | 132 | |
134 | return xxopen(f); | | 133 | return xxopen(f); |
135 | } | | 134 | } |