ofw_machdep.c revision 119338
138776Snsouch/*- 293023Snsouch * Copyright (c) 2001 by Thomas Moestl <tmm@FreeBSD.org>. 338776Snsouch * All rights reserved. 438776Snsouch * 538776Snsouch * Redistribution and use in source and binary forms, with or without 638776Snsouch * modification, are permitted provided that the following conditions 738776Snsouch * are met: 838776Snsouch * 1. Redistributions of source code must retain the above copyright 938776Snsouch * notice, this list of conditions and the following disclaimer. 1038776Snsouch * 2. Redistributions in binary form must reproduce the above copyright 1138776Snsouch * notice, this list of conditions and the following disclaimer in the 1238776Snsouch * documentation and/or other materials provided with the distribution. 1338776Snsouch * 1438776Snsouch * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1538776Snsouch * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1638776Snsouch * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1738776Snsouch * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 1838776Snsouch * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 1938776Snsouch * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 2038776Snsouch * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 2138776Snsouch * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2238776Snsouch * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 2338776Snsouch * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2438776Snsouch * 2538776Snsouch * $FreeBSD: head/sys/sparc64/sparc64/ofw_machdep.c 119338 2003-08-23 00:11:16Z imp $ 2638776Snsouch */ 2738776Snsouch 28119419Sobrien/* 29119419Sobrien * Some OpenFirmware helper functions that are likely machine dependent. 30119419Sobrien */ 3138776Snsouch 3238776Snsouch#include <sys/param.h> 33162234Sjhb#include <sys/systm.h> 3438776Snsouch 35162234Sjhb#include <net/ethernet.h> 3638776Snsouch 3738776Snsouch#include <dev/ofw/openfirm.h> 3838776Snsouch 3938776Snsouch#include <machine/idprom.h> 4038776Snsouch#include <machine/ofw_machdep.h> 4138776Snsouch 4238776Snsouchvoid 4338776SnsouchOF_getetheraddr(device_t dev, u_char *addr) 4438776Snsouch{ 4538776Snsouch phandle_t node; 4638776Snsouch struct idprom idp; 4738776Snsouch 48162234Sjhb node = OF_peer(0); 4938776Snsouch if (node <= 0 || OF_getprop(node, "idprom", &idp, sizeof(idp)) == -1) 5038776Snsouch panic("Could not determine the machine ethernet address"); 51162234Sjhb bcopy(&idp.id_ether, addr, ETHER_ADDR_LEN); 5238776Snsouch} 5338776Snsouch