bad:
outw(0x8A00, 0x8A00);
outw(0x8A00, 0x8E00);
- while (1)
+ while(1)
/* do nothing */;
}
real_cons_putc(int c)
{
int crtport = 0x3d4; // io port of CGA
- unsigned short *crt = (unsigned short *) 0xB8000; // base of CGA memory
+ uint16_t *crt = (uint16_t *) 0xB8000; // base of CGA memory
int ind;
if(panicked){
char buf[16];
char digits[] = "0123456789ABCDEF";
int i = 0, neg = 0;
- unsigned int x;
+ uint x;
if(sgn && xx < 0){
neg = 1;
cprintf(char *fmt, ...)
{
int i, state = 0, c;
- unsigned int *ap = (unsigned int *)(void*)&fmt + 1;
+ uint *ap = (uint *)(void*)&fmt + 1;
if(use_console_lock)
acquire(&console_lock);
void idtinit(void);
// string.c
-void * memset(void *dst, int c, unsigned n);
-int memcmp(const void *v1, const void *v2, unsigned n);
-void *memmove(void *dst, const void *src, unsigned n);
-int strncmp(const char *p, const char *q, unsigned n);
+void * memset(void *dst, int c, uint n);
+int memcmp(const void *v1, const void *v2, uint n);
+void *memmove(void *dst, const void *src, uint n);
+int strncmp(const char *p, const char *q, uint n);
// syscall.c
void syscall(void);
void release1(struct spinlock * lock, struct proc *);
// main.c
-void load_icode(struct proc *p, uint8_t *binary, unsigned size);
+void load_icode(struct proc *p, uint8_t *binary, uint size);
// pipe.c
struct pipe;
// ide.c
void ide_init(void);
void ide_intr(void);
-void* ide_start_read(uint32_t secno, void *dst, unsigned nsecs);
+void* ide_start_read(uint32_t secno, void *dst, uint nsecs);
int ide_finish_read(void *);
struct ide_request {
uint32_t secno;
void *dst;
- unsigned nsecs;
+ uint nsecs;
};
struct ide_request request[NREQUEST];
int head, tail;
}
void *
-ide_start_read(uint32_t secno, void *dst, unsigned nsecs)
+ide_start_read(uint32_t secno, void *dst, uint nsecs)
{
struct ide_request *r;
}
int
-ide_write(uint32_t secno, const void *src, unsigned nsecs)
+ide_write(uint32_t secno, const void *src, uint nsecs)
{
int r;
kinit(void)
{
extern int end;
- unsigned mem;
+ uint mem;
char *start;
start = (char *) &end;
- start = (char *) (((unsigned)start + PAGE) & ~(PAGE-1));
+ start = (char *) (((uint)start + PAGE) & ~(PAGE-1));
mem = 256; // XXX
cprintf("mem = %d\n", mem * PAGE);
kfree(start, mem * PAGE);
p = copyproc(&proc[0]);
- load_icode(p, _binary_usertests_start, (unsigned) _binary_usertests_size);
- //load_icode(p, _binary_userfs_start, (unsigned) _binary_userfs_size);
+ load_icode(p, _binary_usertests_start, (uint) _binary_usertests_size);
+ //load_icode(p, _binary_userfs_start, (uint) _binary_userfs_size);
p->state = RUNNABLE;
cprintf("loaded userfs\n");
}
void
-load_icode(struct proc *p, uint8_t *binary, unsigned size)
+load_icode(struct proc *p, uint8_t *binary, uint size)
{
int i;
struct Elf *elf;
// Segment Descriptors
struct Segdesc {
- unsigned lim_15_0 : 16; // Low bits of segment limit
- unsigned base_15_0 : 16; // Low bits of segment base address
- unsigned base_23_16 : 8; // Middle bits of segment base address
- unsigned type : 4; // Segment type (see STS_ constants)
- unsigned s : 1; // 0 = system, 1 = application
- unsigned dpl : 2; // Descriptor Privilege Level
- unsigned p : 1; // Present
- unsigned lim_19_16 : 4; // High bits of segment limit
- unsigned avl : 1; // Unused (available for software use)
- unsigned rsv1 : 1; // Reserved
- unsigned db : 1; // 0 = 16-bit segment, 1 = 32-bit segment
- unsigned g : 1; // Granularity: limit scaled by 4K when set
- unsigned base_31_24 : 8; // High bits of segment base address
+ 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
+ uint type : 4; // Segment type (see STS_ constants)
+ uint s : 1; // 0 = system, 1 = application
+ uint dpl : 2; // Descriptor Privilege Level
+ uint p : 1; // Present
+ uint lim_19_16 : 4; // High bits of segment limit
+ uint avl : 1; // Unused (available for software use)
+ uint rsv1 : 1; // Reserved
+ uint db : 1; // 0 = 16-bit segment, 1 = 32-bit segment
+ uint g : 1; // Granularity: limit scaled by 4K when set
+ 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 }
// Normal segment
#define SEG(type, base, lim, dpl) (struct Segdesc) \
{ ((lim) >> 12) & 0xffff, (base) & 0xffff, ((base) >> 16) & 0xff, \
- type, 1, dpl, 1, (unsigned) (lim) >> 28, 0, 0, 1, 1, \
- (unsigned) (base) >> 24 }
+ type, 1, dpl, 1, (uint) (lim) >> 28, 0, 0, 1, 1, \
+ (uint) (base) >> 24 }
#define SEG16(type, base, lim, dpl) (struct Segdesc) \
{ (lim) & 0xffff, (base) & 0xffff, ((base) >> 16) & 0xff, \
- type, 1, dpl, 1, (unsigned) (lim) >> 16, 0, 0, 1, 0, \
- (unsigned) (base) >> 24 }
+ type, 1, dpl, 1, (uint) (lim) >> 16, 0, 0, 1, 0, \
+ (uint) (base) >> 24 }
#endif /* !__ASSEMBLER__ */
// Gate descriptors for interrupts and traps
struct Gatedesc {
- unsigned off_15_0 : 16; // low 16 bits of offset in segment
- unsigned ss : 16; // segment selector
- unsigned args : 5; // # args, 0 for interrupt/trap gates
- unsigned rsv1 : 3; // reserved(should be zero I guess)
- unsigned type : 4; // type(STS_{TG,IG32,TG32})
- unsigned s : 1; // must be 0 (system)
- unsigned dpl : 2; // descriptor(meaning new) privilege level
- unsigned p : 1; // Present
- unsigned off_31_16 : 16; // high bits of offset in segment
+ 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
+ uint rsv1 : 3; // reserved(should be zero I guess)
+ uint type : 4; // type(STS_{TG,IG32,TG32})
+ uint s : 1; // must be 0 (system)
+ uint dpl : 2; // descriptor(meaning new) privilege level
+ uint p : 1; // Present
+ uint off_31_16 : 16; // high bits of offset in segment
};
// Set up a normal interrupt/trap gate descriptor.
for(c = 0; c < ncpu; c++){
if (c == cpu()) continue;
cprintf ("starting processor %d\n", c);
- *(unsigned *)(APBOOTCODE-4) = (unsigned) (cpus[c].mpstack) + MPSTACK; // tell it what to use for %esp
- *(unsigned *)(APBOOTCODE-8) = (unsigned)mpmain; // tell it where to jump to
+ *(uint *)(APBOOTCODE-4) = (uint) (cpus[c].mpstack) + MPSTACK; // tell it what to use for %esp
+ *(uint *)(APBOOTCODE-8) = (uint)mpmain; // tell it where to jump to
lapic_startap(cpus[c].apicid, (uint32_t) APBOOTCODE);
}
}
{
memset(&p->ts, 0, sizeof(struct Taskstate));
p->ts.ss0 = SEG_KDATA << 3;
- p->ts.esp0 = (unsigned)(p->kstack + KSTACKSIZE);
+ p->ts.esp0 = (uint)(p->kstack + KSTACKSIZE);
// XXX it may be wrong to modify the current segment table!
p->gdt[0] = SEG_NULL;
p->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0);
p->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
- p->gdt[SEG_TSS] = SEG16(STS_T32A, (unsigned) &p->ts,
+ p->gdt[SEG_TSS] = SEG16(STS_T32A, (uint) &p->ts,
sizeof(p->ts), 0);
p->gdt[SEG_TSS].s = 0;
- p->gdt[SEG_UCODE] = SEG(STA_X|STA_R, (unsigned)p->mem, p->sz, 3);
- p->gdt[SEG_UDATA] = SEG(STA_W, (unsigned)p->mem, p->sz, 3);
+ p->gdt[SEG_UCODE] = SEG(STA_X|STA_R, (uint)p->mem, p->sz, 3);
+ p->gdt[SEG_UDATA] = SEG(STA_W, (uint)p->mem, p->sz, 3);
}
// Look in the process table for an UNUSED proc.
// Set up new jmpbuf to start executing at forkret (see below).
memset(&np->jmpbuf, 0, sizeof np->jmpbuf);
- np->jmpbuf.eip = (unsigned)forkret;
- np->jmpbuf.esp = (unsigned)np->tf;
+ np->jmpbuf.eip = (uint)forkret;
+ np->jmpbuf.esp = (uint)np->tf;
// Copy file descriptors
for(i = 0; i < NOFILE; i++){
struct proc{
char *mem; // start of process's physical memory
- unsigned sz; // total size of mem, including kernel stack
+ uint sz; // total size of mem, including kernel stack
char *kstack; // kernel stack, separate from mem so it doesn't move
enum proc_state state;
enum proc_state newstate; // desired state after swtch()
struct Taskstate ts; // only to give cpu address of kernel stack
struct Segdesc gdt[NSEGS];
- unsigned esp; // kernel stack pointer
- unsigned ebp; // kernel frame pointer
+ uint esp; // kernel stack pointer
+ uint ebp; // kernel frame pointer
struct jmpbuf jmpbuf;
struct spinlock {
- unsigned int locked;
- unsigned locker_pc;
+ uint locked;
+ uint locker_pc;
};
#include "defs.h"
void *
-memset(void *dst, int c, unsigned n)
+memset(void *dst, int c, uint n)
{
char *d = (char *) dst;
}
int
-memcmp(const void *v1, const void *v2, unsigned n)
+memcmp(const void *v1, const void *v2, uint n)
{
const uint8_t *s1 = (const uint8_t *) v1;
const uint8_t *s2 = (const uint8_t *) v2;
}
void *
-memmove(void *dst, const void *src, unsigned n)
+memmove(void *dst, const void *src, uint n)
{
const char *s;
char *d;
}
int
-strncmp(const char *p, const char *q, unsigned n)
+strncmp(const char *p, const char *q, uint n)
{
while (n > 0 && *p && *p == *q)
n--, p++, q++;
if (n == 0)
return 0;
else
- return (int) ((unsigned char) *p - (unsigned char) *q);
+ return (int) ((uint8_t) *p - (uint8_t) *q);
}
// Memcpy is deprecated and should NOT be called.
// Memcpy is here only because gcc compiles some
// structure assignments into calls to memcpy.
void *
-memcpy(void *dst, void *src, unsigned n)
+memcpy(void *dst, void *src, uint n)
{
char *d = (char *) dst;
char *s = (char *) src;
* returns 0 if addr was OK, -1 if illegal.
*/
int
-fetchint(struct proc *p, unsigned addr, int *ip)
+fetchint(struct proc *p, uint addr, int *ip)
{
*ip = 0;
// Fetch byte from a user-supplied pointer.
// Returns 0 on success, -1 if pointer is illegal.
int
-fetchbyte(struct proc *p, unsigned addr, char* c)
+fetchbyte(struct proc *p, uint addr, char* c)
{
if(addr >= p->sz)
return -1;
int
fetcharg(int argno, void *ip)
{
- unsigned esp;
+ uint esp;
- esp = (unsigned) curproc[cpu()]->tf->esp;
+ esp = (uint) curproc[cpu()]->tf->esp;
return fetchint(curproc[cpu()], esp + 4 + 4*argno, ip);
}
int
-putint(struct proc *p, unsigned addr, int ip)
+putint(struct proc *p, uint addr, int ip)
{
if(addr > p->sz - 4)
return -1;
struct fd *rfd = 0, *wfd = 0;
int f1 = -1, f2 = -1;
struct proc *p = curproc[cpu()];
- unsigned fdp;
+ uint fdp;
if(pipe_alloc(&rfd, &wfd) < 0)
goto oops;
sys_write(void)
{
int fd, n, ret;
- unsigned addr;
+ uint addr;
struct proc *p = curproc[cpu()];
if(fetcharg(0, &fd) < 0 || fetcharg(1, &addr) < 0 || fetcharg(2, &n) < 0)
sys_read(void)
{
int fd, n, ret;
- unsigned addr;
+ uint addr;
struct proc *p = curproc[cpu()];
if(fetcharg(0, &fd) < 0 || fetcharg(1, &addr) < 0 || fetcharg(2, &n) < 0)
{
char buf[256];
int i;
- unsigned addr;
+ uint addr;
struct proc *cp = curproc[cpu()];
if(fetcharg(0, &addr) < 0)
sys_panic(void)
{
struct proc *p = curproc[cpu()];
- unsigned int addr;
+ uint addr;
if(fetcharg(0, &addr) < 0)
return -1;
#include "syscall.h"
struct Gatedesc idt[256];
-extern unsigned vectors[]; /* vectors.S, array of 256 entry point addresses */
+extern uint vectors[]; /* vectors.S, array of 256 entry point addresses */
extern void trapenter(void);
extern void trapenter1(void);
}
if((read_eflags() & FL_IF) == 0)
panic("syscall returning but FL_IF clear");
- if(read_esp() < (unsigned)cp->kstack ||
- read_esp() >= (unsigned)cp->kstack + KSTACKSIZE)
+ if(read_esp() < (uint)cp->kstack ||
+ read_esp() >= (uint)cp->kstack + KSTACKSIZE)
panic("trap ret esp wrong");
if(cp->killed)
proc_exit();
+typedef unsigned int uint;
+
typedef unsigned long long uint64_t;
-typedef unsigned int uint32_t;
-typedef unsigned short uint16_t;
-typedef unsigned char uint8_t;
-typedef uint32_t uintptr_t;
-typedef uint32_t physaddr_t;
-typedef unsigned int uint;
+typedef unsigned int uint32_t;
+typedef unsigned short uint16_t;
+typedef unsigned char uint8_t;
+
+typedef uint32_t uintptr_t;
+typedef uint32_t physaddr_t;