add OF_setprop()

This commit is contained in:
macallan 2007-02-28 20:30:57 +00:00
parent 2b64520a8c
commit 12dd6f9c02
2 changed files with 69 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: openfirm.c,v 1.5 2005/12/11 12:16:51 christos Exp $ */ /* $NetBSD: openfirm.c,v 1.6 2007/02/28 20:31:40 macallan Exp $ */
/* /*
* Copyright 1997 * Copyright 1997
@ -65,7 +65,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.5 2005/12/11 12:16:51 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.6 2007/02/28 20:31:40 macallan Exp $");
#include <sys/param.h> #include <sys/param.h>
@ -237,6 +237,39 @@ OF_getprop(handle, prop, buf, buflen)
return args.size; return args.size;
} }
int
OF_setprop(handle, prop, buf, buflen)
int handle;
const char *prop;
const void *buf;
int buflen;
{
static struct {
const char *name;
int nargs;
int nreturns;
int phandle;
const char *prop;
const void *buf;
int buflen;
int size;
} args = {
"setprop",
4,
1,
};
args.phandle = handle;
args.prop = prop;
args.buf = buf;
args.buflen = buflen;
if (openfirmware(&args) == -1)
return -1;
return args.size;
}
int int
OF_getproplen(handle, prop) OF_getproplen(handle, prop)
int handle; int handle;

View File

@ -1,4 +1,4 @@
/* $NetBSD: openfirm.c,v 1.17 2006/01/22 22:53:56 ross Exp $ */ /* $NetBSD: openfirm.c,v 1.18 2007/02/28 20:30:57 macallan Exp $ */
/* /*
* Copyright (C) 1995, 1996 Wolfgang Solfrank. * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.17 2006/01/22 22:53:56 ross Exp $"); __KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.18 2007/02/28 20:30:57 macallan Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -195,6 +195,38 @@ OF_getprop(int handle, const char *prop, void *buf, int buflen)
return args.size; return args.size;
} }
int
OF_setprop(int handle, const char *prop, const void *buf, int buflen)
{
struct {
const char *name;
int nargs;
int nreturns;
int phandle;
const char *prop;
const void *buf;
int buflen;
int size;
} args = {
"setprop",
4,
1
};
ofw_stack();
if (buflen > NBPG)
return -1;
ofbcopy(buf, OF_buf, buflen);
args.phandle = handle;
args.prop = prop;
args.buf = OF_buf;
args.buflen = buflen;
if (openfirmware(&args) == -1)
return -1;
return args.size;
}
int int
OF_nextprop(int handle, const char *prop, void *nextprop) OF_nextprop(int handle, const char *prop, void *nextprop)
{ {