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