openfirm.c (86557) | openfirm.c (109623) |
---|---|
1/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */ 2 3/* 4 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5 * Copyright (C) 1995, 1996 TooLs GmbH. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 40 unchanged lines hidden (view full) --- 49 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 51 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 52 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 54 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 55 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 * | 1/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */ 2 3/* 4 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5 * Copyright (C) 1995, 1996 TooLs GmbH. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 40 unchanged lines hidden (view full) --- 49 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 51 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 52 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 54 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 55 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 * |
57 * $FreeBSD: head/sys/dev/ofw/openfirm.c 86557 2001-11-18 20:38:44Z tmm $ | 57 * $FreeBSD: head/sys/dev/ofw/openfirm.c 109623 2003-01-21 08:56:16Z alfred $ |
58 */ 59 60#include <sys/param.h> 61#include <sys/kernel.h> 62#include <sys/malloc.h> 63#include <sys/systm.h> 64 65#include <machine/stdarg.h> --- 221 unchanged lines hidden (view full) --- 287 args.buflen = (cell_t)buflen; 288 if (openfirmware(&args) == -1) 289 return -1; 290 return args.size; 291} 292 293/* 294 * Store the value of a property of a package into newly allocated memory (using | 58 */ 59 60#include <sys/param.h> 61#include <sys/kernel.h> 62#include <sys/malloc.h> 63#include <sys/systm.h> 64 65#include <machine/stdarg.h> --- 221 unchanged lines hidden (view full) --- 287 args.buflen = (cell_t)buflen; 288 if (openfirmware(&args) == -1) 289 return -1; 290 return args.size; 291} 292 293/* 294 * Store the value of a property of a package into newly allocated memory (using |
295 * the M_OFWPROP malloc pool and M_WAITOK). elsz is the size of a single element, | 295 * the M_OFWPROP malloc pool and 0). elsz is the size of a single element, |
296 * the number of elements is return in number. 297 */ 298int 299OF_getprop_alloc(phandle_t package, char *propname, int elsz, void **buf) 300{ 301 int len; 302 303 *buf = NULL; 304 if ((len = OF_getproplen(package, propname)) == -1 || 305 len % elsz != 0) 306 return (-1); 307 | 296 * the number of elements is return in number. 297 */ 298int 299OF_getprop_alloc(phandle_t package, char *propname, int elsz, void **buf) 300{ 301 int len; 302 303 *buf = NULL; 304 if ((len = OF_getproplen(package, propname)) == -1 || 305 len % elsz != 0) 306 return (-1); 307 |
308 *buf = malloc(len, M_OFWPROP, M_WAITOK); | 308 *buf = malloc(len, M_OFWPROP, 0); |
309 if (OF_getprop(package, propname, *buf, len) == -1) { 310 free(*buf, M_OFWPROP); 311 *buf = NULL; 312 return (-1); 313 } 314 return (len / elsz); 315} 316 --- 485 unchanged lines hidden --- | 309 if (OF_getprop(package, propname, *buf, len) == -1) { 310 free(*buf, M_OFWPROP); 311 *buf = NULL; 312 return (-1); 313 } 314 return (len / elsz); 315} 316 --- 485 unchanged lines hidden --- |