]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/nvram.c
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * BSD driver for Non-volatile RAM.
30 * Stub functions call the real thing in the Platform Expert.
32 * Suurballe 11 Feb 1999
35 #include <sys/types.h>
36 #include <sys/param.h>
38 extern int PEnvopen ( dev_t
, int, int, struct proc
* );
39 extern int PEnvclose ( dev_t
, int, int, struct proc
* );
40 extern int PEnvread ( long, int, unsigned char *);
41 extern int PEnvwrite ( long, int, unsigned char * );
44 nvopen(dev
, flag
, devtype
, pp
)
49 return PEnvopen(dev
,flag
,devtype
,pp
);
54 nvclose(dev
, flag
, mode
, pp
)
59 return PEnvclose(dev
,flag
,mode
,pp
);
64 nvread(dev
, uio
, ioflag
)
76 offset
= uio
->uio_offset
;
77 size
= uio_resid(uio
);
79 for (read
= 0; read
< size
; read
++, offset
++) {
80 error
= PEnvread(offset
, 1, &cc
);
85 error
= ureadc(c
, uio
);
95 nvwrite(dev_t dev
, struct uio
*uio
, int ioflag
)
104 offset
= uio
->uio_offset
;
105 size
= uio_resid(uio
);
107 for (wrote
= 0; wrote
< size
; wrote
++, offset
++) {
112 cc
= (unsigned char)c
;
113 error
= PEnvwrite(offset
, 1, &cc
);