diff options
| -rw-r--r-- | bootmain.c | 6 | ||||
| -rw-r--r-- | elf.h | 4 | ||||
| -rw-r--r-- | main.c | 12 | ||||
| -rw-r--r-- | mmu.h | 14 | ||||
| -rw-r--r-- | mp.c | 40 | ||||
| -rw-r--r-- | mp.h | 12 | ||||
| -rw-r--r-- | proc.c | 6 | ||||
| -rw-r--r-- | proc.h | 6 | ||||
| -rw-r--r-- | trap.c | 4 | ||||
| -rw-r--r-- | x86.h | 14 | 
10 files changed, 59 insertions, 59 deletions
| @@ -31,7 +31,7 @@   **********************************************************************/  #define SECTSIZE	512 -#define ELFHDR		((struct Elf *) 0x10000) // scratch space +#define ELFHDR		((struct elfhdr *) 0x10000) // scratch space  void readsect(void*, uint32_t);  void readseg(uint32_t, uint32_t, uint32_t); @@ -39,7 +39,7 @@ void readseg(uint32_t, uint32_t, uint32_t);  void  cmain(void)  { -	struct Proghdr *ph, *eph; +	struct proghdr *ph, *eph;  	// read 1st page off disk  	readseg((uint32_t) ELFHDR, SECTSIZE*8, 0); @@ -49,7 +49,7 @@ cmain(void)  		goto bad;  	// load each program segment (ignores ph flags) -	ph = (struct Proghdr *) ((uint8_t *) ELFHDR + ELFHDR->phoff); +	ph = (struct proghdr *) ((uint8_t *) ELFHDR + ELFHDR->phoff);  	eph = ph + ELFHDR->phnum;  	for (; ph < eph; ph++)  		readseg(ph->va, ph->memsz, ph->offset); @@ -1,6 +1,6 @@  #define ELF_MAGIC 0x464C457FU	/* "\x7FELF" in little endian */ -struct Elf { +struct elfhdr {  	uint32_t magic;	// must equal ELF_MAGIC  	uint8_t elf[12];  	uint16_t type; @@ -18,7 +18,7 @@ struct Elf {  	uint16_t shstrndx;  }; -struct Proghdr { +struct proghdr {  	uint32_t type;  	uint32_t offset;  	uint32_t va; @@ -57,8 +57,8 @@ main0(void)    p->mem = kalloc(p->sz);    memset(p->mem, 0, p->sz);    p->kstack = kalloc(KSTACKSIZE); -  p->tf = (struct Trapframe *) (p->kstack + KSTACKSIZE - sizeof(struct Trapframe)); -  memset(p->tf, 0, sizeof(struct Trapframe)); +  p->tf = (struct trapframe *) (p->kstack + KSTACKSIZE - sizeof(struct trapframe)); +  memset(p->tf, 0, sizeof(struct trapframe));    p->tf->es = p->tf->ds = p->tf->ss = (SEG_UDATA << 3) | 3;    p->tf->cs = (SEG_UCODE << 3) | 3;    p->tf->eflags = FL_IF; @@ -110,11 +110,11 @@ void  load_icode(struct proc *p, uint8_t *binary, uint size)  {    int i; -  struct Elf *elf; -  struct Proghdr *ph; +  struct elfhdr *elf; +  struct proghdr *ph;    // Check magic number on binary -  elf = (struct Elf*) binary; +  elf = (struct elfhdr*) binary;    cprintf("elf %x magic %x\n", elf, elf->magic);    if (elf->magic != ELF_MAGIC)      panic("load_icode: not an ELF binary"); @@ -123,7 +123,7 @@ load_icode(struct proc *p, uint8_t *binary, uint size)    p->tf->esp = p->sz;    // Map and load segments as directed. -  ph = (struct Proghdr*) (binary + elf->phoff); +  ph = (struct proghdr*) (binary + elf->phoff);    for (i = 0; i < elf->phnum; i++, ph++) {      if (ph->type != ELF_PROG_LOAD)        continue; @@ -60,7 +60,7 @@  #else	// not __ASSEMBLER__  // Segment Descriptors -struct Segdesc { +struct segdesc {  	uint lim_15_0 : 16;  // Low bits of segment limit  	uint base_15_0 : 16; // Low bits of segment base address  	uint base_23_16 : 8; // Middle bits of segment base address @@ -76,15 +76,15 @@ struct Segdesc {  	uint base_31_24 : 8; // High bits of segment base address  };  // Null segment -#define SEG_NULL	(struct Segdesc){ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +#define SEG_NULL	(struct segdesc){ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }  // Segment that is loadable but faults when used -#define SEG_FAULT	(struct Segdesc){ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0 } +#define SEG_FAULT	(struct segdesc){ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0 }  // Normal segment -#define SEG(type, base, lim, dpl) (struct Segdesc)			\ +#define SEG(type, base, lim, dpl) (struct segdesc)			\  { ((lim) >> 12) & 0xffff, (base) & 0xffff, ((base) >> 16) & 0xff,	\      type, 1, dpl, 1, (uint) (lim) >> 28, 0, 0, 1, 1,		\      (uint) (base) >> 24 } -#define SEG16(type, base, lim, dpl) (struct Segdesc)			\ +#define SEG16(type, base, lim, dpl) (struct segdesc)			\  { (lim) & 0xffff, (base) & 0xffff, ((base) >> 16) & 0xff,		\      type, 1, dpl, 1, (uint) (lim) >> 16, 0, 0, 1, 0,		\      (uint) (base) >> 24 } @@ -123,7 +123,7 @@ struct Segdesc {  #ifndef __ASSEMBLER__  // Task state segment format (as described by the Pentium architecture book) -struct Taskstate { +struct taskstate {  	uint32_t link;	// Old ts selector  	uintptr_t esp0;	// Stack pointers and segment selectors  	uint16_t ss0;	//   after an increase in privilege level @@ -164,7 +164,7 @@ struct Taskstate {  };  // Gate descriptors for interrupts and traps -struct Gatedesc { +struct gatedesc {  	uint off_15_0 : 16;   // low 16 bits of offset in segment  	uint ss : 16;         // segment selector  	uint args : 5;        // # args, 0 for interrupt/trap gates @@ -31,12 +31,12 @@ static char* buses[] = {  #define APBOOTCODE 0x7000 // XXX hack -static struct MP* mp;  // The MP floating point structure +static struct mp* mp;  // The MP floating point structure  struct cpu cpus[NCPU];  int ncpu;  static struct cpu *bcpu; -static struct MP* +static struct mp*  mp_scan(uint8_t *addr, int len)  {    uint8_t *e, *p, sum; @@ -44,24 +44,24 @@ mp_scan(uint8_t *addr, int len)    cprintf("scanning: 0x%x\n", (uint32_t)addr);    e = addr+len; -  for(p = addr; p < e; p += sizeof(struct MP)){ +  for(p = addr; p < e; p += sizeof(struct mp)){      if(memcmp(p, "_MP_", 4))        continue;      sum = 0; -    for(i = 0; i < sizeof(struct MP); i++) +    for(i = 0; i < sizeof(struct mp); i++)        sum += p[i];      if(sum == 0) -      return (struct MP *)p; +      return (struct mp *)p;    }    return 0;  } -static struct MP* +static struct mp*  mp_search(void)  {    uint8_t *bda;    uint32_t p; -  struct MP *mp; +  struct mp *mp;    /*     * Search for the MP Floating Pointer Structure, which according to the @@ -86,7 +86,7 @@ mp_search(void)  static int   mp_detect(void)  { -  struct MPCTB *pcmp; +  struct mpctb *pcmp;    uint8_t *p, sum;    uint32_t length; @@ -100,7 +100,7 @@ mp_detect(void)    if((mp = mp_search()) == 0 || mp->physaddr == 0)      return 1; -  pcmp = (struct MPCTB *) mp->physaddr; +  pcmp = (struct mpctb *) mp->physaddr;    if(memcmp(pcmp, "PCMP", 4))      return 2; @@ -121,9 +121,9 @@ mp_init(void)  {     int r;    uint8_t *p, *e; -  struct MPCTB *mpctb; -  struct MPPE *proc; -  struct MPBE *bus; +  struct mpctb *mpctb; +  struct mppe *proc; +  struct mpbe *bus;    int i;    ncpu = 0; @@ -136,40 +136,40 @@ mp_init(void)     * application processors and initialising any I/O APICs. The table     * is guaranteed to be in order such that only one pass is necessary.     */ -  mpctb = (struct MPCTB *) mp->physaddr; +  mpctb = (struct mpctb *) mp->physaddr;    lapicaddr = (uint32_t *) mpctb->lapicaddr;    cprintf("apicaddr: %x\n", lapicaddr); -  p = ((uint8_t*)mpctb)+sizeof(struct MPCTB); +  p = ((uint8_t*)mpctb)+sizeof(struct mpctb);    e = ((uint8_t*)mpctb)+mpctb->length;    while(p < e) {      switch(*p){      case MPPROCESSOR: -      proc = (struct MPPE *) p; +      proc = (struct mppe *) p;        cpus[ncpu].apicid = proc->apicid;        cprintf("a processor %x\n", cpus[ncpu].apicid);        if (proc->flags & MPBP) {  	bcpu = &cpus[ncpu];        }        ncpu++; -      p += sizeof(struct MPPE); +      p += sizeof(struct mppe);        continue;      case MPBUS: -      bus = (struct MPBE *) p; +      bus = (struct mpbe *) p;        for(i = 0; buses[i]; i++){  	if(strncmp(buses[i], bus->string, sizeof(bus->string)) == 0)  	  break;        }        cprintf("a bus %d\n", i); -      p += sizeof(struct MPBE); +      p += sizeof(struct mpbe);        continue;      case MPIOAPIC:        cprintf("an I/O APIC\n"); -      p += sizeof(struct MPIOAPIC); +      p += sizeof(struct mpioapic);        continue;      case MPIOINTR:        cprintf("an I/O intr\n"); -      p += sizeof(struct MPIE); +      p += sizeof(struct mpie);        continue;      default:        cprintf("mpinit: unknown PCMP type 0x%x (e-p 0x%x)\n", *p, e-p); @@ -4,7 +4,7 @@   * Credit: Plan 9 sources   */ -struct MP {			/* floating pointer */ +struct mp {			/* floating pointer */    uint8_t signature[4];		/* "_MP_" */    physaddr_t physaddr;	        /* physical address of MP configuration table */    uint8_t length;		/* 1 */ @@ -15,7 +15,7 @@ struct MP {			/* floating pointer */    uint8_t reserved[3];  }; -struct MPCTB {			/* configuration table header */ +struct mpctb {			/* configuration table header */    uint8_t signature[4];		/* "PCMP" */    uint16_t length;		/* total table length */    uint8_t version;		/* [14] */ @@ -30,7 +30,7 @@ struct MPCTB {			/* configuration table header */    uint8_t reserved;  }; -struct MPPE {		/* processor table entry */ +struct mppe {		/* processor table entry */    uint8_t type;			/* entry type (0) */    uint8_t apicid;		/* local APIC id */    uint8_t version;		/* local APIC verison */ @@ -40,13 +40,13 @@ struct MPPE {		/* processor table entry */    uint8_t reserved[8];  }; -struct MPBE {		/* bus table entry */ +struct mpbe {		/* bus table entry */    uint8_t type;			/* entry type (1) */    uint8_t busno;		/* bus id */    char string[6];		/* bus type string */  }; -struct MPIOAPIC {	/* I/O APIC table entry */ +struct mpioapic {	/* I/O APIC table entry */    uint8_t type;			/* entry type (2) */    uint8_t apicno;		/* I/O APIC id */    uint8_t version;		/* I/O APIC version */ @@ -54,7 +54,7 @@ struct MPIOAPIC {	/* I/O APIC table entry */    uintptr_t addr;		/* I/O APIC address */  }; -struct MPIE {		/* interrupt table entry */ +struct mpie {		/* interrupt table entry */    uint8_t type;			/* entry type ([34]) */    uint8_t intr;			/* interrupt type */    uint16_t flags;		/* interrupt flag */ @@ -13,7 +13,7 @@ struct proc proc[NPROC];  struct proc *curproc[NCPU];  int next_pid = 1;  extern void forkret(void); -extern void forkret1(struct Trapframe*); +extern void forkret1(struct trapframe*);  /*   * set up a process's task state and segment descriptors @@ -24,7 +24,7 @@ extern void forkret1(struct Trapframe*);  void  setupsegs(struct proc *p)  { -  memset(&p->ts, 0, sizeof(struct Taskstate)); +  memset(&p->ts, 0, sizeof(struct taskstate));    p->ts.ss0 = SEG_KDATA << 3;    p->ts.esp0 = (uint)(p->kstack + KSTACKSIZE); @@ -100,7 +100,7 @@ copyproc(struct proc* p)    setupsegs(np);    // Copy trapframe registers from parent. -  np->tf = (struct Trapframe*)(np->kstack + KSTACKSIZE) - 1; +  np->tf = (struct trapframe*)(np->kstack + KSTACKSIZE) - 1;    *np->tf = *p->tf;    // Clear %eax so that fork system call returns 0 in child. @@ -48,14 +48,14 @@ struct proc{    int killed;    struct fd *fds[NOFILE]; -  struct Taskstate ts;  // only to give cpu address of kernel stack -  struct Segdesc gdt[NSEGS]; +  struct taskstate ts;  // only to give cpu address of kernel stack +  struct segdesc gdt[NSEGS];    uint esp; // kernel stack pointer    uint ebp; // kernel frame pointer    struct jmpbuf jmpbuf; -  struct Trapframe *tf; // points into kstack, used to find user regs +  struct trapframe *tf; // points into kstack, used to find user regs  };  extern struct proc proc[]; @@ -7,7 +7,7 @@  #include "traps.h"  #include "syscall.h" -struct Gatedesc idt[256]; +struct gatedesc idt[256];  extern uint vectors[]; /* vectors.S, array of 256 entry point addresses */  extern void trapenter(void); @@ -31,7 +31,7 @@ idtinit(void)  }  void -trap(struct Trapframe *tf) +trap(struct trapframe *tf)  {    int v = tf->trapno; @@ -12,10 +12,10 @@ static __inline void outsw(int port, const void *addr, int cnt) __attribute__((a  static __inline void outsl(int port, const void *addr, int cnt) __attribute__((always_inline));  static __inline void outl(int port, uint32_t data) __attribute__((always_inline));  static __inline void invlpg(void *addr) __attribute__((always_inline)); -struct Segdesc; -static __inline void lgdt(struct Segdesc *p, int) __attribute__((always_inline)); -struct Gatedesc; -static __inline void lidt(struct Gatedesc *p, int) __attribute__((always_inline)); +struct segdesc; +static __inline void lgdt(struct segdesc *p, int) __attribute__((always_inline)); +struct gatedesc; +static __inline void lidt(struct gatedesc *p, int) __attribute__((always_inline));  static __inline void lldt(uint16_t sel) __attribute__((always_inline));  static __inline void ltr(uint16_t sel) __attribute__((always_inline));  static __inline void lcr0(uint32_t val) __attribute__((always_inline)); @@ -144,7 +144,7 @@ invlpg(void *addr)  }    static __inline void -lgdt(struct Segdesc *p, int size) +lgdt(struct segdesc *p, int size)  {  	volatile uint16_t pd[3]; @@ -156,7 +156,7 @@ lgdt(struct Segdesc *p, int size)  }  static __inline void -lidt(struct Gatedesc *p, int size) +lidt(struct gatedesc *p, int size)  {  	volatile uint16_t pd[3]; @@ -339,7 +339,7 @@ sti(void)  	__asm__ volatile("sti");  } -struct Trapframe { +struct trapframe {      /* registers as pushed by pusha */      uint32_t edi;      uint32_t esi; | 
