linux/drivers/macintosh/nvram.c
<<
>>
Prefs
   1/*
   2 * /dev/nvram driver for Power Macintosh.
   3 */
   4
   5#define NVRAM_VERSION "1.0"
   6
   7#include <linux/module.h>
   8
   9#include <linux/types.h>
  10#include <linux/errno.h>
  11#include <linux/fs.h>
  12#include <linux/miscdevice.h>
  13#include <linux/fcntl.h>
  14#include <linux/nvram.h>
  15#include <linux/init.h>
  16#include <asm/uaccess.h>
  17#include <asm/nvram.h>
  18
  19#define NVRAM_SIZE      8192
  20
  21static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
  22{
  23        switch (origin) {
  24        case 0:
  25                break;
  26        case 1:
  27                offset += file->f_pos;
  28                break;
  29        case 2:
  30                offset += NVRAM_SIZE;
  31                break;
  32        default:
  33                offset = -1;
  34        }
  35        if (offset < 0)
  36                return -EINVAL;
  37
  38        file->f_pos = offset;
  39        return file->f_pos;
  40}
  41
  42static ssize_t read_nvram(struct file *file, char __user *buf,
  43                          size_t count, loff_t *ppos)
  44{
  45        unsigned int i;
  46        char __user *p = buf
4 38        if!= buf count)
4943                return -5038        if> *ppos-&g += NVRAM_SIZE)
5 31                retur0a>5 32      r foa= i > *ppos count-&g 0 &&nt i <= NVRAM_SIZEipcount5 43                if (put=__usamnvra">reabytile" class="sref">nvra">reabytiami p)
5443                        return -5 45      > *pposi;
5 46        return pbuf}
5 18
5942static ssize_t file *file,onst>, char __user *buf,
6 30                           size_t count, loff_t *ppos)
6144{
6 32        unsigned int i;
6 43      ,onst>, char __user *p = buf6 24        char 6518
6 46        if!= buf count)
                return -6 38        if> *ppos-&g += NVRAM_SIZE)
6943                retur0a>7 30      r foa= i > *ppos count-&g 0 &&nt i <= NVRAM_SIZEipcount) {
7 31                if (get=__usam p)
7231                        return -7 33                nvrawriteabytile" class="sref">nvrawriteabytiam i7 34        }
7 45      > *pposi;
7 46        return pbuf7 18
7942statilong   nvraioctlle" class="sref">nvraioctlam(struct file *file  unsigned int   unsignelong   8044{
8 31        swita= ) {
8231                cas= NVRAGET_OFFSETAL" class="srefPMAC_">NVRAGET_OFFSET318 33              ) {
8443                      d int offset;
8 25                      d if (__usersioff (8 36                                return -                      d if (8 28                                return -EINVAL;
8943                      > offset;
9 30                      d if (__useroffset">sioff (offset9 31                                return -9231                        break;
9 33              a>}
9  4
9 25                default:
9 36                        return -EINVAL;
      a>}
9  8
9 39        retur0a>}

>(struct        . (      . (nvram_llseek,
      . (reek" class="sref">re36          += read_nvram,
      . (      . (nvraioctlle" class="sref">nvraioctlam,

stati>(struct nvrascdet      =       > &quoh/nvr.0",
      &t 
x/in_t         &quor Macinto non-volstale memoryam drivev%s\n.0",
              = NVRAM_VERSION;
        return nvrascdet;
}
}
exin_t {
      n nvrascdet;
}

&quoGPL.0";
The ">origal LXR software by thas= LXR ="cou/inyeth(th experiommeal riveion by = lin.no">lxs@l>lin.noet lxs.l>lin.no kindly hostud by = lpro.no">Redpill L>lpro ASetprovider of L>lux ,onsulttri and operaactip serdevip since 1995.
/bodyiv /htmliv