types h defs h
play

types.h defs.h Page 1/1 Page 1/3 typedef unsigned int uint; struct - PDF document

types.h defs.h Page 1/1 Page 1/3 typedef unsigned int uint; struct buf; typedef unsigned short ushort; struct context; typedef unsigned char uchar; struct file; typedef uint pde_t; struct inode; struct pipe; 5 struct proc; struct spinlock;


  1. types.h defs.h Page 1/1 Page 1/3 typedef unsigned int uint; struct buf; typedef unsigned short ushort; struct context; typedef unsigned char uchar; struct file; typedef uint pde_t; struct inode; struct pipe; 5 struct proc; struct spinlock; struct stat; struct superblock; 10 // bio.c void binit( void ); struct buf* bread(uint, uint); void brelse( struct buf*); void bwrite( struct buf*); 15 // console.c void consoleinit( void ); void cprintf( char *, ...); void consoleintr( int (*)( void )); 20 void panic( char *) __attribute__((noreturn)); // exec.c int exec( char *, char **); 25 // file.c struct file* filealloc( void ); void fileclose( struct file*); struct file* filedup( struct file*); void fileinit( void ); 30 int fileread( struct file*, char *, int n); int filestat( struct file*, struct stat*); int filewrite( struct file*, char *, int n); // fs.c 35 void readsb( int dev, struct superblock *sb); int dirlink( struct inode*, char *, uint); struct inode* dirlookup( struct inode*, char *, uint*); struct inode* ialloc(uint, short ); struct inode* idup( struct inode*); 40 void iinit( void ); void ilock( struct inode*); void iput( struct inode*); void iunlock( struct inode*); void iunlockput( struct inode*); 45 void iupdate( struct inode*); int namecmp( const char *, const char *); struct inode* namei( char *); struct inode* nameiparent( char *, char *); int readi( struct inode*, char *, uint, uint); 50 void stati( struct inode*, struct stat*); int writei( struct inode*, char *, uint, uint); // ide.c void ideinit( void ); 55 void ideintr( void ); void iderw( struct buf*); // ioapic.c void ioapicenable( int irq, int cpu); 60 extern uchar ioapicid; void ioapicinit( void ); // kalloc.c defs.h defs.h Page 2/3 Page 3/3 char * kalloc( void ); void pushcli( void ); 65 void kfree( char *); void popcli( void ); 130 void kinit1( void *, void *); void kinit2( void *, void *); // string.c int memcmp( const void *, const void *, uint); // kbd.c void * memmove( void *, const void *, uint); 70 void kbdintr( void ); void * memset( void *, int , uint); 135 char * safestrcpy( char *, const char *, int ); // lapic.c int strlen( const char *); int cpunum( void ); int strncmp( const char *, const char *, uint); extern volatile uint* lapic; char * strncpy( char *, const char *, int ); 75 void lapiceoi( void ); 140 void lapicinit( void ); // syscall.c void lapicstartap(uchar, uint); int argint( int , int *); void microdelay( int ); int argptr( int , char **, int ); int argstr( int , char **); 80 // log.c int fetchint(uint, int *); 145 void initlog( void ); int fetchstr(uint, char **); void log_write( struct buf*); void syscall( void ); void begin_trans(); void commit_trans(); // timer.c 85 void timerinit( void ); 150 // mp.c extern int ismp; // trap.c int mpbcpu( void ); void idtinit( void ); void mpinit( void ); extern uint ticks; 90 void mpstartthem( void ); void tvinit( void ); 155 extern struct spinlock tickslock; // picirq.c void picenable( int ); // uart.c void picinit( void ); void uartinit( void ); 95 void uartintr( void ); 160 // pipe.c void uartputc( int ); int pipealloc( struct file**, struct file**); void pipeclose( struct pipe*, int ); // vm.c int piperead( struct pipe*, char *, int ); void seginit( void ); 100 int pipewrite( struct pipe*, char *, int ); void kvmalloc( void ); 165 void vmenable( void ); //PAGEBREAK: 16 pde_t* setupkvm( void ); // proc.c char * uva2ka(pde_t*, char *); struct proc* copyproc( struct proc*); int allocuvm(pde_t*, uint, uint); 105 void exit( void ); int deallocuvm(pde_t*, uint, uint); 170 int fork( void ); void freevm(pde_t*); int growproc( int ); void inituvm(pde_t*, char *, uint); int kill( int ); int loaduvm(pde_t*, char *, struct inode*, uint, uint); void pinit( void ); pde_t* copyuvm(pde_t*, uint); 110 void procdump( void ); void switchuvm( struct proc*); 175 void scheduler( void ) __attribute__((noreturn)); void switchkvm( void ); void sched( void ); int copyout(pde_t*, uint, void *, uint); void sleep( void *, struct spinlock*); void clearpteu(pde_t *pgdir, char *uva); void userinit( void ); 115 int wait( void ); // number of elements in fixed − size array 180 void wakeup( void *); #define NELEM(x) ( sizeof (x)/ sizeof ((x)[0])) void yield( void ); // swtch.S 120 void swtch( struct context**, struct context*); // spinlock.c void acquire( struct spinlock*); void getcallerpcs( void *, uint*); 125 int holding( struct spinlock*); void initlock( struct spinlock*, char *); void release( struct spinlock*); 1/18

  2. param.h proc.h Page 1/1 Page 1/2 #define NPROC 64 // maximum number of processes // Segments in proc − >gdt. #define KSTACKSIZE 4096 // size of per − process kernel stack #define NSEGS 7 #define NCPU 8 // maximum number of CPUs #define NOFILE 16 // open files per process // Per − CPU state #define NFILE 100 // open files per system struct cpu { 5 5 #define NBUF 10 // size of disk block cache uchar id; // Local APIC ID; index into cpus[] below #define NINODE 50 // maximum number of active i − nodes struct context *scheduler; // swtch() here to enter scheduler #define NDEV 10 // maximum major device number struct taskstate ts; // Used by x86 to find stack for interrupt #define ROOTDEV 1 // device number of file system root disk struct segdesc gdt[NSEGS]; // x86 global descriptor table #define MAXARG 32 // max exec arguments volatile uint started; // Has the CPU started? 10 10 #define LOGSIZE 10 // max data sectors in on − disk log int ncli; // Depth of pushcli nesting. int intena; // Were interrupts enabled before pushcli? // Cpu − local storage variables; see below struct cpu *cpu; 15 struct proc *proc; // The currently − running process. }; extern struct cpu cpus[NCPU]; extern int ncpu; 20 // Per − CPU variables, holding pointers to the // current cpu and to the current process. // The asm suffix tells gcc to use "%gs:0" to refer to cpu // and "%gs:4" to refer to proc. seginit sets up the 25 // %gs segment register so that %gs refers to the memory // holding those two variables in the local cpu’s struct cpu. // This is similar to how thread − local variables are implemented // in thread libraries such as Linux pthreads. extern struct cpu *cpu asm ("%gs:0"); // &cpus[cpunum()] 30 extern struct proc *proc asm ("%gs:4"); // cpus[cpunum()].proc //PAGEBREAK: 17 // Saved registers for kernel context switches. // Don’t need to save all the segment registers (%cs, etc), 35 // because they are constant across kernel contexts. // Don’t need to save %eax, %ecx, %edx, because the // x86 convention is that the caller has saved them. // Contexts are stored at the bottom of the stack they // describe; the stack pointer is the address of the context. 40 // The layout of the context matches the layout of the stack in swtch.S // at the "Switch stacks" comment. Switch doesn’t save eip explicitly, // but it is on the stack and allocproc() manipulates it. struct context { uint edi; 45 uint esi; uint ebx; uint ebp; uint eip; }; 50 enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; // Per − process state struct proc { 55 uint sz; // Size of process memory (bytes) pde_t* pgdir; // Page table char *kstack; // Bottom of kernel stack for this process enum procstate state; // Process state volatile int pid; // Process ID 60 struct proc *parent; // Parent process struct trapframe *tf; // Trap frame for current syscall struct context *context; // swtch() here to run process void *chan; // If non − zero, sleeping on chan proc.h memlayout.h Page 2/2 Page 1/1 int killed; // If non − zero, have been killed // Memory layout 65 struct file *ofile[NOFILE]; // Open files struct inode *cwd; // Current directory #define EXTMEM 0x100000 // Start of extended memory char name[16]; // Process name (debugging) #define PHYSTOP 0xE000000 // Top physical memory }; #define DEVSPACE 0xFE000000 // Other devices are at high addresses 5 70 // Process memory is laid out contiguously, low addresses first: // Key addresses for address space layout (see kmap in vm.c for layout) // text #define KERNBASE 0x80000000 // First kernel virtual address // original data and bss #define KERNLINK (KERNBASE+EXTMEM) // Address where kernel is linked // fixed − size stack 10 // expandable heap #ifndef __ASSEMBLER__ 75 static inline uint v2p( void *a) { return ((uint) (a)) − KERNBASE; } static inline void *p2v(uint a) { return ( void *) ((a) + KERNBASE); } 15 #endif #define V2P(a) (((uint) (a)) − KERNBASE) #define P2V(a) ((( void *) (a)) + KERNBASE) 20 #define V2P_WO(x) ((x) − KERNBASE) // same as V2P, but without casts #define P2V_WO(x) ((x) + KERNBASE) // same as V2P, but without casts 2/18

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend