| @@ -1,165 +1,166 @@ | | | @@ -1,165 +1,166 @@ |
1 | /* $NetBSD: openbios.c,v 1.6 2021/03/30 01:47:45 rin Exp $ */ | | 1 | /* $NetBSD: openbios.c,v 1.7 2021/03/30 01:50:13 rin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2004 Shigeyuki Fukushima. | | 4 | * Copyright (c) 2004 Shigeyuki Fukushima. |
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 form must reproduce the above | | 12 | * 2. Redistributions in binary form must reproduce the above |
13 | * copyright notice, this list of conditions and the following | | 13 | * copyright notice, this list of conditions and the following |
14 | * disclaimer in the documentation and/or other materials provided | | 14 | * disclaimer in the documentation and/or other materials provided |
15 | * with the distribution. | | 15 | * with the distribution. |
16 | * 3. The name of the author may not be used to endorse or promote | | 16 | * 3. The name of the author may not be used to endorse or promote |
17 | * products derived from this software without specific prior | | 17 | * products derived from this software without specific prior |
18 | * written permission. | | 18 | * written permission. |
19 | * | | 19 | * |
20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | | 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | | 21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | | 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | | 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: openbios.c,v 1.6 2021/03/30 01:47:45 rin Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: openbios.c,v 1.7 2021/03/30 01:50:13 rin Exp $"); |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | | 37 | #include <sys/systm.h> |
38 | #include <sys/cpu.h> | | 38 | #include <sys/cpu.h> |
39 | | | 39 | |
40 | #include <powerpc/ibm4xx/cpu.h> | | 40 | #include <powerpc/ibm4xx/cpu.h> |
41 | #include <powerpc/ibm4xx/openbios.h> | | 41 | #include <powerpc/ibm4xx/openbios.h> |
42 | | | 42 | |
43 | /* | | 43 | /* |
44 | * Board configuration structure from the OpenBIOS. | | 44 | * Board configuration structure from the OpenBIOS. |
45 | * | | 45 | * |
46 | * Supported (XXX): | | 46 | * Supported (XXX): |
| | | 47 | * IBM/AMCC Walnut PowerPC 405GP Evaluation Board |
47 | * 405GPr 1.2 ROM Monitor (5/25/02) | | 48 | * 405GPr 1.2 ROM Monitor (5/25/02) |
48 | */ | | 49 | */ |
49 | struct board_bios_data { | | 50 | struct board_bios_data { |
50 | unsigned char usr_config_ver[4]; | | 51 | unsigned char usr_config_ver[4]; |
51 | unsigned char rom_sw_ver[30]; | | 52 | unsigned char rom_sw_ver[30]; |
52 | unsigned int mem_size; | | 53 | unsigned int mem_size; |
53 | unsigned char mac_address_local[6]; | | 54 | unsigned char mac_address_local[6]; |
54 | unsigned char mac_address_pci[6]; | | 55 | unsigned char mac_address_pci[6]; |
55 | unsigned int processor_speed; | | 56 | unsigned int processor_speed; |
56 | unsigned int plb_speed; | | 57 | unsigned int plb_speed; |
57 | unsigned int pci_speed; | | 58 | unsigned int pci_speed; |
58 | }; | | 59 | }; |
59 | | | 60 | |
60 | static struct board_bios_data board_bios; | | 61 | static struct board_bios_data board_bios; |
61 | | | 62 | |
62 | void | | 63 | void |
63 | openbios_board_init(void *info_block) | | 64 | openbios_board_init(void *info_block) |
64 | { | | 65 | { |
65 | | | 66 | |
66 | /* Initialize cache info for memcpy, etc. */ | | 67 | /* Initialize cache info for memcpy, etc. */ |
67 | cpu_probe_cache(); | | 68 | cpu_probe_cache(); |
68 | | | 69 | |
69 | /* Save info block */ | | 70 | /* Save info block */ |
70 | memcpy(&board_bios, info_block, sizeof(board_bios)); | | 71 | memcpy(&board_bios, info_block, sizeof(board_bios)); |
71 | } | | 72 | } |
72 | | | 73 | |
73 | unsigned int | | 74 | unsigned int |
74 | openbios_board_memsize_get(void) | | 75 | openbios_board_memsize_get(void) |
75 | { | | 76 | { |
| | | 77 | |
76 | return board_bios.mem_size; | | 78 | return board_bios.mem_size; |
77 | } | | 79 | } |
78 | | | 80 | |
79 | void | | 81 | void |
80 | openbios_board_info_set(void) | | 82 | openbios_board_info_set(void) |
81 | { | | 83 | { |
82 | prop_number_t pn; | | 84 | prop_number_t pn; |
83 | prop_string_t ps; | | 85 | prop_string_t ps; |
84 | prop_data_t pd; | | 86 | prop_data_t pd; |
85 | | | 87 | |
86 | /* Initialize board properties database */ | | 88 | /* Initialize board properties database */ |
87 | board_info_init(); | | 89 | board_info_init(); |
88 | | | 90 | |
89 | ps = prop_string_create_cstring_nocopy(board_bios.usr_config_ver); | | 91 | ps = prop_string_create_cstring_nocopy(board_bios.usr_config_ver); |
90 | KASSERT(ps != NULL); | | 92 | KASSERT(ps != NULL); |
91 | if (prop_dictionary_set(board_properties, "user-config-version", | | 93 | if (prop_dictionary_set(board_properties, "user-config-version", |
92 | ps) == false) | | 94 | ps) == false) |
93 | panic("setting user-config-version"); | | 95 | panic("setting user-config-version"); |
94 | prop_object_release(ps); | | 96 | prop_object_release(ps); |
95 | | | 97 | |
96 | ps = prop_string_create_cstring_nocopy(board_bios.rom_sw_ver); | | 98 | ps = prop_string_create_cstring_nocopy(board_bios.rom_sw_ver); |
97 | KASSERT(ps != NULL); | | 99 | KASSERT(ps != NULL); |
98 | if (prop_dictionary_set(board_properties, "rom-software-version", | | 100 | if (prop_dictionary_set(board_properties, "rom-software-version", |
99 | ps) == false) | | 101 | ps) == false) |
100 | panic("setting rom-software-version"); | | 102 | panic("setting rom-software-version"); |
101 | prop_object_release(ps); | | 103 | prop_object_release(ps); |
102 | | | 104 | |
103 | pn = prop_number_create_integer(board_bios.mem_size); | | 105 | pn = prop_number_create_integer(board_bios.mem_size); |
104 | KASSERT(pn != NULL); | | 106 | KASSERT(pn != NULL); |
105 | if (prop_dictionary_set(board_properties, "mem-size", pn) == false) | | 107 | if (prop_dictionary_set(board_properties, "mem-size", pn) == false) |
106 | panic("setting mem-size"); | | 108 | panic("setting mem-size"); |
107 | prop_object_release(pn); | | 109 | prop_object_release(pn); |
108 | | | 110 | |
109 | pd = prop_data_create_data_nocopy(board_bios.mac_address_local, | | 111 | pd = prop_data_create_data_nocopy(board_bios.mac_address_local, |
110 | sizeof(board_bios.mac_address_local)); | | 112 | sizeof(board_bios.mac_address_local)); |
111 | KASSERT(pd != NULL); | | 113 | KASSERT(pd != NULL); |
112 | if (prop_dictionary_set(board_properties, "emac0-mac-addr", | | 114 | if (prop_dictionary_set(board_properties, "emac0-mac-addr", |
113 | pd) == false) | | 115 | pd) == false) |
114 | panic("setting emac0-mac-addr"); | | 116 | panic("setting emac0-mac-addr"); |
115 | prop_object_release(pd); | | 117 | prop_object_release(pd); |
116 | | | 118 | |
117 | pd = prop_data_create_data_nocopy(board_bios.mac_address_pci, | | 119 | pd = prop_data_create_data_nocopy(board_bios.mac_address_pci, |
118 | sizeof(board_bios.mac_address_pci)); | | 120 | sizeof(board_bios.mac_address_pci)); |
119 | KASSERT(pd != NULL); | | 121 | KASSERT(pd != NULL); |
120 | if (prop_dictionary_set(board_properties, "sip0-mac-addr", | | 122 | if (prop_dictionary_set(board_properties, "sip0-mac-addr", |
121 | pd) == false) | | 123 | pd) == false) |
122 | panic("setting sip0-mac-addr"); | | 124 | panic("setting sip0-mac-addr"); |
123 | prop_object_release(pd); | | 125 | prop_object_release(pd); |
124 | | | 126 | |
125 | pn = prop_number_create_integer(board_bios.processor_speed); | | 127 | pn = prop_number_create_integer(board_bios.processor_speed); |
126 | KASSERT(pn != NULL); | | 128 | KASSERT(pn != NULL); |
127 | if (prop_dictionary_set(board_properties, "processor-frequency", | | 129 | if (prop_dictionary_set(board_properties, "processor-frequency", |
128 | pn) == false) | | 130 | pn) == false) |
129 | panic("setting processor-frequency"); | | 131 | panic("setting processor-frequency"); |
130 | prop_object_release(pn); | | 132 | prop_object_release(pn); |
131 | | | 133 | |
132 | pn = prop_number_create_integer(board_bios.plb_speed); | | 134 | pn = prop_number_create_integer(board_bios.plb_speed); |
133 | KASSERT(pn != NULL); | | 135 | KASSERT(pn != NULL); |
134 | if (prop_dictionary_set(board_properties, "plb-frequency", pn) == false) | | 136 | if (prop_dictionary_set(board_properties, "plb-frequency", pn) == false) |
135 | panic("setting plb-frequency"); | | 137 | panic("setting plb-frequency"); |
136 | prop_object_release(pn); | | 138 | prop_object_release(pn); |
137 | | | 139 | |
138 | pn = prop_number_create_integer(board_bios.pci_speed); | | 140 | pn = prop_number_create_integer(board_bios.pci_speed); |
139 | KASSERT(pn != NULL); | | 141 | KASSERT(pn != NULL); |
140 | if (prop_dictionary_set(board_properties, "pci-frequency", pn) == false) | | 142 | if (prop_dictionary_set(board_properties, "pci-frequency", pn) == false) |
141 | panic("setting pci-frequency"); | | 143 | panic("setting pci-frequency"); |
142 | prop_object_release(pn); | | 144 | prop_object_release(pn); |
143 | } | | 145 | } |
144 | | | 146 | |
145 | | | | |
146 | void | | 147 | void |
147 | openbios_board_print(void) | | 148 | openbios_board_print(void) |
148 | { | | 149 | { |
149 | | | 150 | |
150 | printf("Board config data:\n"); | | 151 | printf("Board config data:\n"); |
151 | printf(" usr_config_ver = %s\n", board_bios.usr_config_ver); | | 152 | printf(" usr_config_ver = %s\n", board_bios.usr_config_ver); |
152 | printf(" rom_sw_ver = %s\n", board_bios.rom_sw_ver); | | 153 | printf(" rom_sw_ver = %s\n", board_bios.rom_sw_ver); |
153 | printf(" mem_size = %u\n", board_bios.mem_size); | | 154 | printf(" mem_size = %u\n", board_bios.mem_size); |
154 | printf(" mac_address_local = %02x:%02x:%02x:%02x:%02x:%02x\n", | | 155 | printf(" mac_address_local = %02x:%02x:%02x:%02x:%02x:%02x\n", |
155 | board_bios.mac_address_local[0], board_bios.mac_address_local[1], | | 156 | board_bios.mac_address_local[0], board_bios.mac_address_local[1], |
156 | board_bios.mac_address_local[2], board_bios.mac_address_local[3], | | 157 | board_bios.mac_address_local[2], board_bios.mac_address_local[3], |
157 | board_bios.mac_address_local[4], board_bios.mac_address_local[5]); | | 158 | board_bios.mac_address_local[4], board_bios.mac_address_local[5]); |
158 | printf(" mac_address_pci = %02x:%02x:%02x:%02x:%02x:%02x\n", | | 159 | printf(" mac_address_pci = %02x:%02x:%02x:%02x:%02x:%02x\n", |
159 | board_bios.mac_address_pci[0], board_bios.mac_address_pci[1], | | 160 | board_bios.mac_address_pci[0], board_bios.mac_address_pci[1], |
160 | board_bios.mac_address_pci[2], board_bios.mac_address_pci[3], | | 161 | board_bios.mac_address_pci[2], board_bios.mac_address_pci[3], |
161 | board_bios.mac_address_pci[4], board_bios.mac_address_pci[5]); | | 162 | board_bios.mac_address_pci[4], board_bios.mac_address_pci[5]); |
162 | printf(" processor_speed = %u\n", board_bios.processor_speed); | | 163 | printf(" processor_speed = %u\n", board_bios.processor_speed); |
163 | printf(" plb_speed = %u\n", board_bios.plb_speed); | | 164 | printf(" plb_speed = %u\n", board_bios.plb_speed); |
164 | printf(" pci_speed = %u\n", board_bios.pci_speed); | | 165 | printf(" pci_speed = %u\n", board_bios.pci_speed); |
165 | } | | 166 | } |