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