The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/port/portdat.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 typedef struct Alarms   Alarms;
    2 typedef struct Block    Block;
    3 typedef struct Chan     Chan;
    4 typedef struct Cmdbuf   Cmdbuf;
    5 typedef struct Cmdtab   Cmdtab;
    6 typedef struct Confmem  Confmem;
    7 typedef struct Dev      Dev;
    8 typedef struct Dirtab   Dirtab;
    9 typedef struct Edf      Edf;
   10 typedef struct Egrp     Egrp;
   11 typedef struct Evalue   Evalue;
   12 typedef struct Fgrp     Fgrp;
   13 typedef struct DevConf  DevConf;
   14 typedef struct Image    Image;
   15 typedef struct Log      Log;
   16 typedef struct Logflag  Logflag;
   17 typedef struct Mntcache Mntcache;
   18 typedef struct Mount    Mount;
   19 typedef struct Mntrpc   Mntrpc;
   20 typedef struct Mntwalk  Mntwalk;
   21 typedef struct Mnt      Mnt;
   22 typedef struct Mhead    Mhead;
   23 typedef struct Note     Note;
   24 typedef struct Page     Page;
   25 typedef struct Path     Path;
   26 typedef struct Palloc   Palloc;
   27 typedef struct Pallocmem        Pallocmem;
   28 typedef struct Perf     Perf;
   29 typedef struct PhysUart PhysUart;
   30 typedef struct Pgrp     Pgrp;
   31 typedef struct Physseg  Physseg;
   32 typedef struct Proc     Proc;
   33 typedef struct Pte      Pte;
   34 typedef struct QLock    QLock;
   35 typedef struct Queue    Queue;
   36 typedef struct Ref      Ref;
   37 typedef struct Rendez   Rendez;
   38 typedef struct Rgrp     Rgrp;
   39 typedef struct RWlock   RWlock;
   40 typedef struct Sargs    Sargs;
   41 typedef struct Schedq   Schedq;
   42 typedef struct Segment  Segment;
   43 typedef struct Sema     Sema;
   44 typedef struct Timer    Timer;
   45 typedef struct Timers   Timers;
   46 typedef struct Uart     Uart;
   47 typedef struct Waitq    Waitq;
   48 typedef struct Walkqid  Walkqid;
   49 typedef struct Watchdog Watchdog;
   50 typedef int    Devgen(Chan*, char*, Dirtab*, int, int, Dir*);
   51 
   52 #pragma incomplete DevConf
   53 #pragma incomplete Edf
   54 #pragma incomplete Mntcache
   55 #pragma incomplete Mntrpc
   56 #pragma incomplete Queue
   57 #pragma incomplete Timers
   58 
   59 #include <fcall.h>
   60 
   61 struct Ref
   62 {
   63         Lock;
   64         long    ref;
   65 };
   66 
   67 struct Rendez
   68 {
   69         Lock;
   70         Proc    *p;
   71 };
   72 
   73 struct QLock
   74 {
   75         Lock    use;            /* to access Qlock structure */
   76         Proc    *head;          /* next process waiting for object */
   77         Proc    *tail;          /* last process waiting for object */
   78         int     locked;         /* flag */
   79 };
   80 
   81 struct RWlock
   82 {
   83         Lock    use;
   84         Proc    *head;          /* list of waiting processes */
   85         Proc    *tail;
   86         ulong   wpc;            /* pc of writer */
   87         Proc    *wproc;         /* writing proc */
   88         int     readers;        /* number of readers */
   89         int     writer;         /* number of writers */
   90 };
   91 
   92 struct Alarms
   93 {
   94         QLock;
   95         Proc    *head;
   96 };
   97 
   98 struct Sargs
   99 {
  100         ulong   args[MAXSYSARG];
  101 };
  102 
  103 /*
  104  * Access types in namec & channel flags
  105  */
  106 enum
  107 {
  108         Aaccess,                        /* as in stat, wstat */
  109         Abind,                          /* for left-hand-side of bind */
  110         Atodir,                         /* as in chdir */
  111         Aopen,                          /* for i/o */
  112         Amount,                         /* to be mounted or mounted upon */
  113         Acreate,                        /* is to be created */
  114         Aremove,                        /* will be removed by caller */
  115 
  116         COPEN   = 0x0001,               /* for i/o */
  117         CMSG    = 0x0002,               /* the message channel for a mount */
  118 /*rsc   CCREATE = 0x0004,               /* permits creation if c->mnt */
  119         CCEXEC  = 0x0008,               /* close on exec */
  120         CFREE   = 0x0010,               /* not in use */
  121         CRCLOSE = 0x0020,               /* remove on close */
  122         CCACHE  = 0x0080,               /* client cache */
  123 };
  124 
  125 /* flag values */
  126 enum
  127 {
  128         BINTR   =       (1<<0),
  129         BFREE   =       (1<<1),
  130         Bipck   =       (1<<2),         /* ip checksum */
  131         Budpck  =       (1<<3),         /* udp checksum */
  132         Btcpck  =       (1<<4),         /* tcp checksum */
  133         Bpktck  =       (1<<5),         /* packet checksum */
  134 };
  135 
  136 struct Block
  137 {
  138         long    ref;
  139         Block*  next;
  140         Block*  list;
  141         uchar*  rp;                     /* first unconsumed byte */
  142         uchar*  wp;                     /* first empty byte */
  143         uchar*  lim;                    /* 1 past the end of the buffer */
  144         uchar*  base;                   /* start of the buffer */
  145         void    (*free)(Block*);
  146         ushort  flag;
  147         ushort  checksum;               /* IP checksum of complete packet (minus media header) */
  148 };
  149 
  150 #define BLEN(s) ((s)->wp - (s)->rp)
  151 #define BALLOC(s) ((s)->lim - (s)->base)
  152 
  153 struct Chan
  154 {
  155         Ref;                            /* the Lock in this Ref is also Chan's lock */
  156         Chan*   next;                   /* allocation */
  157         Chan*   link;
  158         vlong   offset;                 /* in fd */
  159         vlong   devoffset;              /* in underlying device; see read */
  160         ushort  type;
  161         ulong   dev;
  162         ushort  mode;                   /* read/write */
  163         ushort  flag;
  164         Qid     qid;
  165         int     fid;                    /* for devmnt */
  166         ulong   iounit;                 /* chunk size for i/o; 0==default */
  167         Mhead*  umh;                    /* mount point that derived Chan; used in unionread */
  168         Chan*   umc;                    /* channel in union; held for union read */
  169         QLock   umqlock;                /* serialize unionreads */
  170         int     uri;                    /* union read index */
  171         int     dri;                    /* devdirread index */
  172         uchar*  dirrock;                /* directory entry rock for translations */
  173         int     nrock;
  174         int     mrock;
  175         QLock   rockqlock;
  176         int     ismtpt;
  177         Mntcache*mcp;                   /* Mount cache pointer */
  178         Mnt*    mux;                    /* Mnt for clients using me for messages */
  179         union {
  180                 void*   aux;
  181                 Qid     pgrpid;         /* for #p/notepg */
  182                 ulong   mid;            /* for ns in devproc */
  183         };
  184         Chan*   mchan;                  /* channel to mounted server */
  185         Qid     mqid;                   /* qid of root of mount point */
  186         Path*   path;
  187 };
  188 
  189 struct Path
  190 {
  191         Ref;
  192         char    *s;
  193         Chan    **mtpt;                 /* mtpt history */
  194         int     len;                    /* strlen(s) */
  195         int     alen;                   /* allocated length of s */
  196         int     mlen;                   /* number of path elements */
  197         int     malen;                  /* allocated length of mtpt */
  198 };
  199 
  200 struct Dev
  201 {
  202         int     dc;
  203         char*   name;
  204 
  205         void    (*reset)(void);
  206         void    (*init)(void);
  207         void    (*shutdown)(void);
  208         Chan*   (*attach)(char*);
  209         Walkqid*(*walk)(Chan*, Chan*, char**, int);
  210         int     (*stat)(Chan*, uchar*, int);
  211         Chan*   (*open)(Chan*, int);
  212         void    (*create)(Chan*, char*, int, ulong);
  213         void    (*close)(Chan*);
  214         long    (*read)(Chan*, void*, long, vlong);
  215         Block*  (*bread)(Chan*, long, ulong);
  216         long    (*write)(Chan*, void*, long, vlong);
  217         long    (*bwrite)(Chan*, Block*, ulong);
  218         void    (*remove)(Chan*);
  219         int     (*wstat)(Chan*, uchar*, int);
  220         void    (*power)(int);  /* power mgt: power(1) => on, power (0) => off */
  221         int     (*config)(int, char*, DevConf*);        /* returns nil on error */
  222 };
  223 
  224 struct Dirtab
  225 {
  226         char    name[KNAMELEN];
  227         Qid     qid;
  228         vlong   length;
  229         long    perm;
  230 };
  231 
  232 struct Walkqid
  233 {
  234         Chan    *clone;
  235         int     nqid;
  236         Qid     qid[1];
  237 };
  238 
  239 enum
  240 {
  241         NSMAX   =       1000,
  242         NSLOG   =       7,
  243         NSCACHE =       (1<<NSLOG),
  244 };
  245 
  246 struct Mntwalk                          /* state for /proc/#/ns */
  247 {
  248         int     cddone;
  249         Mhead*  mh;
  250         Mount*  cm;
  251 };
  252 
  253 struct Mount
  254 {
  255         ulong   mountid;
  256         Mount*  next;
  257         Mhead*  head;
  258         Mount*  copy;
  259         Mount*  order;
  260         Chan*   to;                     /* channel replacing channel */
  261         int     mflag;
  262         char    *spec;
  263 };
  264 
  265 struct Mhead
  266 {
  267         Ref;
  268         RWlock  lock;
  269         Chan*   from;                   /* channel mounted upon */
  270         Mount*  mount;                  /* what's mounted upon it */
  271         Mhead*  hash;                   /* Hash chain */
  272 };
  273 
  274 struct Mnt
  275 {
  276         Lock;
  277         /* references are counted using c->ref; channels on this mount point incref(c->mchan) == Mnt.c */
  278         Chan    *c;             /* Channel to file service */
  279         Proc    *rip;           /* Reader in progress */
  280         Mntrpc  *queue;         /* Queue of pending requests on this channel */
  281         ulong   id;             /* Multiplexer id for channel check */
  282         Mnt     *list;          /* Free list */
  283         int     flags;          /* cache */
  284         int     msize;          /* data + IOHDRSZ */
  285         char    *version;       /* 9P version */
  286         Queue   *q;             /* input queue */
  287 };
  288 
  289 enum
  290 {
  291         NUser,                          /* note provided externally */
  292         NExit,                          /* deliver note quietly */
  293         NDebug,                         /* print debug message */
  294 };
  295 
  296 struct Note
  297 {
  298         char    msg[ERRMAX];
  299         int     flag;                   /* whether system posted it */
  300 };
  301 
  302 enum
  303 {
  304         PG_NOFLUSH      = 0,
  305         PG_TXTFLUSH     = 1,            /* flush dcache and invalidate icache */
  306         PG_DATFLUSH     = 2,            /* flush both i & d caches (UNUSED) */
  307         PG_NEWCOL       = 3,            /* page has been recolored */
  308 
  309         PG_MOD          = 0x01,         /* software modified bit */
  310         PG_REF          = 0x02,         /* software referenced bit */
  311 };
  312 
  313 struct Page
  314 {
  315         Lock;
  316         ulong   pa;                     /* Physical address in memory */
  317         ulong   va;                     /* Virtual address for user */
  318         ulong   daddr;                  /* Disc address on swap */
  319         ushort  ref;                    /* Reference count */
  320         char    modref;                 /* Simulated modify/reference bits */
  321         char    color;                  /* Cache coloring */
  322         char    cachectl[MAXMACH];      /* Cache flushing control for putmmu */
  323         Image   *image;                 /* Associated text or swap image */
  324         Page    *next;                  /* Lru free list */
  325         Page    *prev;
  326         Page    *hash;                  /* Image hash chains */
  327 };
  328 
  329 struct Swapalloc
  330 {
  331         Lock;                           /* Free map lock */
  332         int     free;                   /* currently free swap pages */
  333         uchar*  swmap;                  /* Base of swap map in memory */
  334         uchar*  alloc;                  /* Round robin allocator */
  335         uchar*  last;                   /* Speed swap allocation */
  336         uchar*  top;                    /* Top of swap map */
  337         Rendez  r;                      /* Pager kproc idle sleep */
  338         ulong   highwater;              /* Pager start threshold */
  339         ulong   headroom;               /* Space pager frees under highwater */
  340 }swapalloc;
  341 
  342 struct Image
  343 {
  344         Ref;
  345         Chan    *c;                     /* channel to text file */
  346         Qid     qid;                    /* Qid for page cache coherence */
  347         Qid     mqid;
  348         Chan    *mchan;
  349         ushort  type;                   /* Device type of owning channel */
  350         Segment *s;                     /* TEXT segment for image if running */
  351         Image   *hash;                  /* Qid hash chains */
  352         Image   *next;                  /* Free list */
  353         int     notext;                 /* no file associated */
  354 };
  355 
  356 struct Pte
  357 {
  358         Page    *pages[PTEPERTAB];      /* Page map for this chunk of pte */
  359         Page    **first;                /* First used entry */
  360         Page    **last;                 /* Last used entry */
  361 };
  362 
  363 /* Segment types */
  364 enum
  365 {
  366         SG_TYPE         = 07,           /* Mask type of segment */
  367         SG_TEXT         = 00,
  368         SG_DATA         = 01,
  369         SG_BSS          = 02,
  370         SG_STACK        = 03,
  371         SG_SHARED       = 04,
  372         SG_PHYSICAL     = 05,
  373 
  374         SG_RONLY        = 0040,         /* Segment is read only */
  375         SG_CEXEC        = 0100,         /* Detach at exec */
  376 };
  377 
  378 #define PG_ONSWAP       1
  379 #define onswap(s)       (((ulong)s)&PG_ONSWAP)
  380 #define pagedout(s)     (((ulong)s)==0 || onswap(s))
  381 #define swapaddr(s)     (((ulong)s)&~PG_ONSWAP)
  382 
  383 #define SEGMAXSIZE      (SEGMAPSIZE*PTEMAPMEM)
  384 
  385 struct Physseg
  386 {
  387         ulong   attr;                   /* Segment attributes */
  388         char    *name;                  /* Attach name */
  389         ulong   pa;                     /* Physical address */
  390         ulong   size;                   /* Maximum segment size in pages */
  391         Page    *(*pgalloc)(Segment*, ulong);   /* Allocation if we need it */
  392         void    (*pgfree)(Page*);
  393 };
  394 
  395 struct Sema
  396 {
  397         Rendez;
  398         long    *addr;
  399         int     waiting;
  400         Sema    *next;
  401         Sema    *prev;
  402 };
  403 
  404 struct Segment
  405 {
  406         Ref;
  407         QLock   lk;
  408         ushort  steal;          /* Page stealer lock */
  409         ushort  type;           /* segment type */
  410         ulong   base;           /* virtual base */
  411         ulong   top;            /* virtual top */
  412         ulong   size;           /* size in pages */
  413         ulong   fstart;         /* start address in file for demand load */
  414         ulong   flen;           /* length of segment in file */
  415         int     flushme;        /* maintain icache for this segment */
  416         Image   *image;         /* text in file attached to this segment */
  417         Physseg *pseg;
  418         ulong*  profile;        /* Tick profile area */
  419         Pte     **map;
  420         int     mapsize;
  421         Pte     *ssegmap[SSEGMAPSIZE];
  422         Lock    semalock;
  423         Sema    sema;
  424         ulong   mark;           /* portcountrefs */
  425 };
  426 
  427 enum
  428 {
  429         RENDLOG =       5,
  430         RENDHASH =      1<<RENDLOG,     /* Hash to lookup rendezvous tags */
  431         MNTLOG  =       5,
  432         MNTHASH =       1<<MNTLOG,      /* Hash to walk mount table */
  433         NFD =           100,            /* per process file descriptors */
  434         PGHLOG  =       9,
  435         PGHSIZE =       1<<PGHLOG,      /* Page hash for image lookup */
  436 };
  437 #define REND(p,s)       ((p)->rendhash[(s)&((1<<RENDLOG)-1)])
  438 #define MOUNTH(p,qid)   ((p)->mnthash[(qid).path&((1<<MNTLOG)-1)])
  439 
  440 struct Pgrp
  441 {
  442         Ref;                            /* also used as a lock when mounting */
  443         int     noattach;
  444         ulong   pgrpid;
  445         QLock   debug;                  /* single access via devproc.c */
  446         RWlock  ns;                     /* Namespace n read/one write lock */
  447         Mhead   *mnthash[MNTHASH];
  448 };
  449 
  450 struct Rgrp
  451 {
  452         Ref;                            /* the Ref's lock is also the Rgrp's lock */
  453         Proc    *rendhash[RENDHASH];    /* Rendezvous tag hash */
  454 };
  455 
  456 struct Egrp
  457 {
  458         Ref;
  459         RWlock;
  460         Evalue  **ent;
  461         int     nent;
  462         int     ment;
  463         ulong   path;   /* qid.path of next Evalue to be allocated */
  464         ulong   vers;   /* of Egrp */
  465 };
  466 
  467 struct Evalue
  468 {
  469         char    *name;
  470         char    *value;
  471         int     len;
  472         Evalue  *link;
  473         Qid     qid;
  474 };
  475 
  476 struct Fgrp
  477 {
  478         Ref;
  479         Chan    **fd;
  480         int     nfd;                    /* number allocated */
  481         int     maxfd;                  /* highest fd in use */
  482         int     exceed;                 /* debugging */
  483 };
  484 
  485 enum
  486 {
  487         DELTAFD = 20            /* incremental increase in Fgrp.fd's */
  488 };
  489 
  490 struct Pallocmem
  491 {
  492         ulong base;
  493         ulong npage;
  494 };
  495 
  496 struct Palloc
  497 {
  498         Lock;
  499         Pallocmem       mem[4];
  500         Page    *head;                  /* most recently used */
  501         Page    *tail;                  /* least recently used */
  502         ulong   freecount;              /* how many pages on free list now */
  503         Page    *pages;                 /* array of all pages */
  504         ulong   user;                   /* how many user pages */
  505         Page    *hash[PGHSIZE];
  506         Lock    hashlock;
  507         Rendez  r;                      /* Sleep for free mem */
  508         QLock   pwait;                  /* Queue of procs waiting for memory */
  509 };
  510 
  511 struct Waitq
  512 {
  513         Waitmsg w;
  514         Waitq   *next;
  515 };
  516 
  517 /*
  518  * fasttick timer interrupts
  519  */
  520 enum {
  521         /* Mode */
  522         Trelative,      /* timer programmed in ns from now */
  523         Tperiodic,      /* periodic timer, period in ns */
  524 };
  525 
  526 struct Timer
  527 {
  528         /* Public interface */
  529         int     tmode;          /* See above */
  530         vlong   tns;            /* meaning defined by mode */
  531         void    (*tf)(Ureg*, Timer*);
  532         void    *ta;
  533         /* Internal */
  534         Lock;
  535         Timers  *tt;            /* Timers queue this timer runs on */
  536         Tval    tticks;         /* tns converted to ticks */
  537         Tval    twhen;          /* ns represented in fastticks */
  538         Timer   *tnext;
  539 };
  540 
  541 enum
  542 {
  543         RFNAMEG         = (1<<0),
  544         RFENVG          = (1<<1),
  545         RFFDG           = (1<<2),
  546         RFNOTEG         = (1<<3),
  547         RFPROC          = (1<<4),
  548         RFMEM           = (1<<5),
  549         RFNOWAIT        = (1<<6),
  550         RFCNAMEG        = (1<<10),
  551         RFCENVG         = (1<<11),
  552         RFCFDG          = (1<<12),
  553         RFREND          = (1<<13),
  554         RFNOMNT         = (1<<14),
  555 };
  556 
  557 /*
  558  *  process memory segments - NSEG always last !
  559  */
  560 enum
  561 {
  562         SSEG, TSEG, DSEG, BSEG, ESEG, LSEG, SEG1, SEG2, SEG3, SEG4, NSEG
  563 };
  564 
  565 enum
  566 {
  567         Dead = 0,               /* Process states */
  568         Moribund,
  569         Ready,
  570         Scheding,
  571         Running,
  572         Queueing,
  573         QueueingR,
  574         QueueingW,
  575         Wakeme,
  576         Broken,
  577         Stopped,
  578         Rendezvous,
  579         Waitrelease,
  580 
  581         Proc_stopme = 1,        /* devproc requests */
  582         Proc_exitme,
  583         Proc_traceme,
  584         Proc_exitbig,
  585         Proc_tracesyscall,
  586 
  587         TUser = 0,              /* Proc.time */
  588         TSys,
  589         TReal,
  590         TCUser,
  591         TCSys,
  592         TCReal,
  593 
  594         NERR = 64,
  595         NNOTE = 5,
  596 
  597         Npriq           = 20,           /* number of scheduler priority levels */
  598         Nrq             = Npriq+2,      /* number of priority levels including real time */
  599         PriRelease      = Npriq,        /* released edf processes */
  600         PriEdf          = Npriq+1,      /* active edf processes */
  601         PriNormal       = 10,           /* base priority for normal processes */
  602         PriExtra        = Npriq-1,      /* edf processes at high best-effort pri */
  603         PriKproc        = 13,           /* base priority for kernel processes */
  604         PriRoot         = 13,           /* base priority for root processes */
  605 };
  606 
  607 struct Schedq
  608 {
  609         Lock;
  610         Proc*   head;
  611         Proc*   tail;
  612         int     n;
  613 };
  614 
  615 struct Proc
  616 {
  617         Label   sched;          /* known to l.s */
  618         char    *kstack;        /* known to l.s */
  619         Mach    *mach;          /* machine running this proc */
  620         char    *text;
  621         char    *user;
  622         char    *args;
  623         int     nargs;          /* number of bytes of args */
  624         Proc    *rnext;         /* next process in run queue */
  625         Proc    *qnext;         /* next process on queue for a QLock */
  626         QLock   *qlock;         /* addr of qlock being queued for DEBUG */
  627         int     state;
  628         char    *psstate;       /* What /proc/#/status reports */
  629         Segment *seg[NSEG];
  630         QLock   seglock;        /* locked whenever seg[] changes */
  631         ulong   pid;
  632         ulong   noteid;         /* Equivalent of note group */
  633         Proc    *pidhash;       /* next proc in pid hash */
  634 
  635         Lock    exl;            /* Lock count and waitq */
  636         Waitq   *waitq;         /* Exited processes wait children */
  637         int     nchild;         /* Number of living children */
  638         int     nwait;          /* Number of uncollected wait records */
  639         QLock   qwaitr;
  640         Rendez  waitr;          /* Place to hang out in wait */
  641         Proc    *parent;
  642 
  643         Pgrp    *pgrp;          /* Process group for namespace */
  644         Egrp    *egrp;          /* Environment group */
  645         Fgrp    *fgrp;          /* File descriptor group */
  646         Rgrp    *rgrp;          /* Rendez group */
  647 
  648         Fgrp    *closingfgrp;   /* used during teardown */
  649 
  650         ulong   parentpid;
  651         ulong   time[6];        /* User, Sys, Real; child U, S, R */
  652 
  653         uvlong  kentry;         /* Kernel entry time stamp (for profiling) */
  654         /*
  655          * pcycles: cycles spent in this process (updated on procsave/restore)
  656          * when this is the current proc and we're in the kernel
  657          * (procrestores outnumber procsaves by one)
  658          * the number of cycles spent in the proc is pcycles + cycles()
  659          * when this is not the current process or we're in user mode
  660          * (procrestores and procsaves balance), it is pcycles.
  661          */
  662         vlong   pcycles;
  663 
  664         int     insyscall;
  665         int     fpstate;
  666 
  667         QLock   debug;          /* to access debugging elements of User */
  668         Proc    *pdbg;          /* the debugging process */
  669         ulong   procmode;       /* proc device file mode */
  670         ulong   privatemem;     /* proc does not let anyone read mem */
  671         int     hang;           /* hang at next exec for debug */
  672         int     procctl;        /* Control for /proc debugging */
  673         ulong   pc;             /* DEBUG only */
  674 
  675         Lock    rlock;          /* sync sleep/wakeup with postnote */
  676         Rendez  *r;             /* rendezvous point slept on */
  677         Rendez  sleep;          /* place for syssleep/debug */
  678         int     notepending;    /* note issued but not acted on */
  679         int     kp;             /* true if a kernel process */
  680         Proc    *palarm;        /* Next alarm time */
  681         ulong   alarm;          /* Time of call */
  682         int     newtlb;         /* Pager has changed my pte's, I must flush */
  683         int     noswap;         /* process is not swappable */
  684 
  685         uintptr rendtag;        /* Tag for rendezvous */
  686         uintptr rendval;        /* Value for rendezvous */
  687         Proc    *rendhash;      /* Hash list for tag values */
  688 
  689         Timer;                  /* For tsleep and real-time */
  690         Rendez  *trend;
  691         int     (*tfn)(void*);
  692         void    (*kpfun)(void*);
  693         void    *kparg;
  694 
  695         FPsave  fpsave;         /* address of this is known by db */
  696         int     scallnr;        /* sys call number - known by db */
  697         Sargs   s;              /* address of this is known by db */
  698         int     nerrlab;
  699         Label   errlab[NERR];
  700         char    *syserrstr;     /* last error from a system call, errbuf0 or 1 */
  701         char    *errstr;        /* reason we're unwinding the error stack, errbuf1 or 0 */
  702         char    errbuf0[ERRMAX];
  703         char    errbuf1[ERRMAX];
  704         char    genbuf[128];    /* buffer used e.g. for last name element from namec */
  705         Chan    *slash;
  706         Chan    *dot;
  707 
  708         Note    note[NNOTE];
  709         short   nnote;
  710         short   notified;       /* sysnoted is due */
  711         Note    lastnote;
  712         int     (*notify)(void*, char*);
  713 
  714         Lock    *lockwait;
  715         Lock    *lastlock;      /* debugging */
  716         Lock    *lastilock;     /* debugging */
  717 
  718         Mach    *wired;
  719         Mach    *mp;            /* machine this process last ran on */
  720         Ref     nlocks;         /* number of locks held by proc */
  721         ulong   delaysched;
  722         ulong   priority;       /* priority level */
  723         ulong   basepri;        /* base priority level */
  724         uchar   fixedpri;       /* priority level deson't change */
  725         ulong   cpu;            /* cpu average */
  726         ulong   lastupdate;
  727         uchar   yield;          /* non-zero if the process just did a sleep(0) */
  728         ulong   readytime;      /* time process came ready */
  729         ulong   movetime;       /* last time process switched processors */
  730         int     preempted;      /* true if this process hasn't finished the interrupt
  731                                  *  that last preempted it
  732                                  */
  733         Edf     *edf;           /* if non-null, real-time proc, edf contains scheduling params */
  734         int     trace;          /* process being traced? */
  735 
  736         ulong   qpc;            /* pc calling last blocking qlock */
  737 
  738         int     setargs;
  739 
  740         void    *ureg;          /* User registers for notes */
  741         void    *dbgreg;        /* User registers for devproc */
  742         Notsave;
  743 
  744         /*
  745          *  machine specific MMU
  746          */
  747         PMMU;
  748 };
  749 
  750 enum
  751 {
  752         PRINTSIZE =     256,
  753         MAXCRYPT =      127,
  754         NUMSIZE =       12,             /* size of formatted number */
  755         MB =            (1024*1024),
  756         /* READSTR was 1000, which is way too small for usb's ctl file */
  757         READSTR =       4000,           /* temporary buffer size for device reads */
  758 };
  759 
  760 extern  Conf    conf;
  761 extern  char*   conffile;
  762 extern  int     cpuserver;
  763 extern  Dev*    devtab[];
  764 extern  char*   eve;
  765 extern  char    hostdomain[];
  766 extern  uchar   initcode[];
  767 extern  int     kbdbuttons;
  768 extern  Queue*  kbdq;
  769 extern  Queue*  kprintoq;
  770 extern  Ref     noteidalloc;
  771 extern  int     nsyscall;
  772 extern  Palloc  palloc;
  773 extern  Queue*  serialoq;
  774 extern  char*   statename[];
  775 extern  Image   swapimage;
  776 extern  char*   sysname;
  777 extern  uint    qiomaxatomic;
  778 
  779 enum
  780 {
  781         LRESPROF        = 3,
  782 };
  783 
  784 /*
  785  *  action log
  786  */
  787 struct Log {
  788         Lock;
  789         int     opens;
  790         char*   buf;
  791         char    *end;
  792         char    *rptr;
  793         int     len;
  794         int     nlog;
  795         int     minread;
  796 
  797         int     logmask;        /* mask of things to debug */
  798 
  799         QLock   readq;
  800         Rendez  readr;
  801 };
  802 
  803 struct Logflag {
  804         char*   name;
  805         int     mask;
  806 };
  807 
  808 enum
  809 {
  810         NCMDFIELD = 128
  811 };
  812 
  813 struct Cmdbuf
  814 {
  815         char    *buf;
  816         char    **f;
  817         int     nf;
  818 };
  819 
  820 struct Cmdtab
  821 {
  822         int     index;  /* used by client to switch on result */
  823         char    *cmd;   /* command name */
  824         int     narg;   /* expected #args; 0 ==> variadic */
  825 };
  826 
  827 /*
  828  *  routines to access UART hardware
  829  */
  830 struct PhysUart
  831 {
  832         char*   name;
  833         Uart*   (*pnp)(void);
  834         void    (*enable)(Uart*, int);
  835         void    (*disable)(Uart*);
  836         void    (*kick)(Uart*);
  837         void    (*dobreak)(Uart*, int);
  838         int     (*baud)(Uart*, int);
  839         int     (*bits)(Uart*, int);
  840         int     (*stop)(Uart*, int);
  841         int     (*parity)(Uart*, int);
  842         void    (*modemctl)(Uart*, int);
  843         void    (*rts)(Uart*, int);
  844         void    (*dtr)(Uart*, int);
  845         long    (*status)(Uart*, void*, long, long);
  846         void    (*fifo)(Uart*, int);
  847         void    (*power)(Uart*, int);
  848         int     (*getc)(Uart*); /* polling versions, for iprint, rdb */
  849         void    (*putc)(Uart*, int);
  850 };
  851 
  852 enum {
  853         Stagesize=      2048
  854 };
  855 
  856 /*
  857  *  software UART
  858  */
  859 struct Uart
  860 {
  861         void*   regs;                   /* hardware stuff */
  862         void*   saveregs;               /* place to put registers on power down */
  863         char*   name;                   /* internal name */
  864         ulong   freq;                   /* clock frequency */
  865         int     bits;                   /* bits per character */
  866         int     stop;                   /* stop bits */
  867         int     parity;                 /* even, odd or no parity */
  868         int     baud;                   /* baud rate */
  869         PhysUart*phys;
  870         int     console;                /* used as a serial console */
  871         int     special;                /* internal kernel device */
  872         Uart*   next;                   /* list of allocated uarts */
  873 
  874         QLock;
  875         int     type;                   /* ?? */
  876         int     dev;
  877         int     opens;
  878 
  879         int     enabled;
  880         Uart    *elist;                 /* next enabled interface */
  881 
  882         int     perr;                   /* parity errors */
  883         int     ferr;                   /* framing errors */
  884         int     oerr;                   /* rcvr overruns */
  885         int     berr;                   /* no input buffers */
  886         int     serr;                   /* input queue overflow */
  887 
  888         /* buffers */
  889         int     (*putc)(Queue*, int);
  890         Queue   *iq;
  891         Queue   *oq;
  892 
  893         Lock    rlock;
  894         uchar   istage[Stagesize];
  895         uchar   *iw;
  896         uchar   *ir;
  897         uchar   *ie;
  898 
  899         Lock    tlock;                  /* transmit */
  900         uchar   ostage[Stagesize];
  901         uchar   *op;
  902         uchar   *oe;
  903         int     drain;
  904 
  905         int     modem;                  /* hardware flow control on */
  906         int     xonoff;                 /* software flow control on */
  907         int     blocked;
  908         int     cts, dsr, dcd;  /* keep track of modem status */ 
  909         int     ctsbackoff;
  910         int     hup_dsr, hup_dcd;       /* send hangup upstream? */
  911         int     dohup;
  912 
  913         Rendez  r;
  914 };
  915 
  916 extern  Uart*   consuart;
  917 
  918 /*
  919  *  performance timers, all units in perfticks
  920  */
  921 struct Perf
  922 {
  923         ulong   intrts;         /* time of last interrupt */
  924         ulong   inintr;         /* time since last clock tick in interrupt handlers */
  925         ulong   avg_inintr;     /* avg time per clock tick in interrupt handlers */
  926         ulong   inidle;         /* time since last clock tick in idle loop */
  927         ulong   avg_inidle;     /* avg time per clock tick in idle loop */
  928         ulong   last;           /* value of perfticks() at last clock tick */
  929         ulong   period;         /* perfticks() per clock tick */
  930 };
  931 
  932 struct Watchdog
  933 {
  934         void    (*enable)(void);        /* watchdog enable */
  935         void    (*disable)(void);       /* watchdog disable */
  936         void    (*restart)(void);       /* watchdog restart */
  937         void    (*stat)(char*, char*);  /* watchdog statistics */
  938 };
  939 
  940 
  941 /* queue state bits,  Qmsg, Qcoalesce, and Qkick can be set in qopen */
  942 enum
  943 {
  944         /* Queue.state */
  945         Qstarve         = (1<<0),       /* consumer starved */
  946         Qmsg            = (1<<1),       /* message stream */
  947         Qclosed         = (1<<2),       /* queue has been closed/hungup */
  948         Qflow           = (1<<3),       /* producer flow controlled */
  949         Qcoalesce       = (1<<4),       /* coallesce packets on read */
  950         Qkick           = (1<<5),       /* always call the kick routine after qwrite */
  951 };
  952 
  953 #define DEVDOTDOT -1
  954 
  955 #pragma varargck        type    "I"     uchar*
  956 #pragma varargck        type    "V"     uchar*
  957 #pragma varargck        type    "E"     uchar*
  958 #pragma varargck        type    "M"     uchar*

Cache object: 32dec6d800df272e34b1a38f6e15461f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.