Annotation of XNU/bsd/dev/ppc/nvram.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  * BSD driver for Non-volatile RAM.
        !            24:  Stub functions call the real thing in the Platform Expert.
        !            25: 
        !            26:  Suurballe 11 Feb 1999
        !            27:  */
        !            28: #include <sys/types.h>
        !            29: #import <sys/param.h>
        !            30: 
        !            31: extern int PEnvopen ( dev_t, int, int, struct proc * );
        !            32: extern int PEnvclose ( dev_t, int, int, struct proc * );
        !            33: extern int PEnvread ( long, int, unsigned char *);
        !            34: extern int PEnvwrite ( long, int, unsigned char * );
        !            35: 
        !            36: 
        !            37: nvopen(dev, flag, devtype, pp)
        !            38:        dev_t dev;
        !            39:        int flag, devtype;
        !            40:        struct proc *pp;
        !            41: {
        !            42:     return PEnvopen(dev,flag,devtype,pp);
        !            43: }
        !            44: 
        !            45: 
        !            46: 
        !            47: nvclose(dev, flag, mode, pp)
        !            48:        dev_t dev;
        !            49:        int flag, mode;
        !            50:        struct proc *pp;
        !            51: {
        !            52:     return PEnvclose(dev,flag,mode,pp);
        !            53: }
        !            54: 
        !            55: 
        !            56: 
        !            57: nvread(dev, uio, ioflag)
        !            58:        dev_t dev;
        !            59:        struct uio *uio;
        !            60:        int ioflag;
        !            61: {
        !            62:     long offset;
        !            63:     long size;
        !            64:     int c;
        !            65:     unsigned char cc;
        !            66:     long       read = 0;
        !            67:     int error = 0;
        !            68: 
        !            69:     offset = uio->uio_offset;
        !            70:     size = uio->uio_resid;
        !            71: 
        !            72:     for (read = 0; read < size; read++, offset++)  {
        !            73:         error = PEnvread(offset, 1, &cc);
        !            74:         if ( error ) {
        !            75:             return error;
        !            76:         }
        !            77:         c = (int)cc;
        !            78:         error = ureadc(c, uio);
        !            79:         if (error) {
        !            80:             return error;
        !            81:         }
        !            82:     }
        !            83:     return error;
        !            84: }
        !            85: 
        !            86: 
        !            87: 
        !            88: nvwrite(dev_t dev,  struct uio *uio, int ioflag)
        !            89: {
        !            90:         register struct iovec *iov;
        !            91:         long offset;
        !            92:         long size;
        !            93:         int c;
        !            94:         unsigned char cc;
        !            95:         long   wrote = 0;
        !            96:         int error = 0;
        !            97: 
        !            98:         offset = uio->uio_offset;
        !            99:         size = uio->uio_resid;
        !           100: 
        !           101:         for (wrote = 0; wrote < size; wrote++, offset++) {
        !           102:             c = uwritec(uio);
        !           103:             if (c < 0) {
        !           104:                 return 0;
        !           105:             }
        !           106:             cc = (unsigned char)c;
        !           107:             error = PEnvwrite(offset, 1, &cc);
        !           108:         }
        !           109:         return error;
        !           110: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.