add uint and standardize on typedefs instead of unsigned
This commit is contained in:
parent
857d60cb0c
commit
b5ee516575
|
@ -61,7 +61,7 @@ cmain(void)
|
|||
bad:
|
||||
outw(0x8A00, 0x8A00);
|
||||
outw(0x8A00, 0x8E00);
|
||||
while (1)
|
||||
while(1)
|
||||
/* do nothing */;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ static void
|
|||
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){
|
||||
|
@ -85,7 +85,7 @@ printint(int xx, int base, int sgn)
|
|||
char buf[16];
|
||||
char digits[] = "0123456789ABCDEF";
|
||||
int i = 0, neg = 0;
|
||||
unsigned int x;
|
||||
uint x;
|
||||
|
||||
if(sgn && xx < 0){
|
||||
neg = 1;
|
||||
|
@ -111,7 +111,7 @@ void
|
|||
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);
|
||||
|
|
12
defs.h
12
defs.h
|
@ -32,10 +32,10 @@ void tvinit(void);
|
|||
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);
|
||||
|
@ -68,7 +68,7 @@ void acquire1(struct spinlock * lock, struct proc *);
|
|||
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;
|
||||
|
@ -89,6 +89,6 @@ void fd_incref(struct fd *fd);
|
|||
// 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 *);
|
||||
|
||||
|
|
6
ide.c
6
ide.c
|
@ -19,7 +19,7 @@
|
|||
struct ide_request {
|
||||
uint32_t secno;
|
||||
void *dst;
|
||||
unsigned nsecs;
|
||||
uint nsecs;
|
||||
};
|
||||
struct ide_request request[NREQUEST];
|
||||
int head, tail;
|
||||
|
@ -104,7 +104,7 @@ ide_start_request (void)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -149,7 +149,7 @@ ide_finish_read(void *c)
|
|||
}
|
||||
|
||||
int
|
||||
ide_write(uint32_t secno, const void *src, unsigned nsecs)
|
||||
ide_write(uint32_t secno, const void *src, uint nsecs)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
|
4
kalloc.c
4
kalloc.c
|
@ -34,11 +34,11 @@ void
|
|||
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);
|
||||
|
|
6
main.c
6
main.c
|
@ -81,8 +81,8 @@ main0(void)
|
|||
|
||||
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");
|
||||
|
||||
|
@ -107,7 +107,7 @@ mpmain(void)
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
52
mmu.h
52
mmu.h
|
@ -61,19 +61,19 @@
|
|||
|
||||
// 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 }
|
||||
|
@ -82,12 +82,12 @@ struct Segdesc {
|
|||
// 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__ */
|
||||
|
||||
|
@ -165,15 +165,15 @@ struct Taskstate {
|
|||
|
||||
// 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.
|
||||
|
|
4
mp.c
4
mp.c
|
@ -205,8 +205,8 @@ mp_startthem(void)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
12
proc.c
12
proc.c
|
@ -26,18 +26,18 @@ setupsegs(struct proc *p)
|
|||
{
|
||||
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.
|
||||
|
@ -108,8 +108,8 @@ copyproc(struct proc* p)
|
|||
|
||||
// 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++){
|
||||
|
|
6
proc.h
6
proc.h
|
@ -37,7 +37,7 @@ enum proc_state { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE };
|
|||
|
||||
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()
|
||||
|
@ -50,8 +50,8 @@ struct proc{
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct spinlock {
|
||||
unsigned int locked;
|
||||
unsigned locker_pc;
|
||||
uint locked;
|
||||
uint locker_pc;
|
||||
};
|
||||
|
|
12
string.c
12
string.c
|
@ -2,7 +2,7 @@
|
|||
#include "defs.h"
|
||||
|
||||
void *
|
||||
memset(void *dst, int c, unsigned n)
|
||||
memset(void *dst, int c, uint n)
|
||||
{
|
||||
char *d = (char *) dst;
|
||||
|
||||
|
@ -13,7 +13,7 @@ memset(void *dst, int c, unsigned n)
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -28,7 +28,7 @@ memcmp(const void *v1, const void *v2, unsigned n)
|
|||
}
|
||||
|
||||
void *
|
||||
memmove(void *dst, const void *src, unsigned n)
|
||||
memmove(void *dst, const void *src, uint n)
|
||||
{
|
||||
const char *s;
|
||||
char *d;
|
||||
|
@ -48,14 +48,14 @@ memmove(void *dst, const void *src, unsigned n)
|
|||
}
|
||||
|
||||
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.
|
||||
|
@ -64,7 +64,7 @@ strncmp(const char *p, const char *q, unsigned n)
|
|||
// 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;
|
||||
|
|
20
syscall.c
20
syscall.c
|
@ -24,7 +24,7 @@
|
|||
* 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;
|
||||
|
||||
|
@ -37,7 +37,7 @@ fetchint(struct proc *p, unsigned addr, int *ip)
|
|||
// 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;
|
||||
|
@ -49,14 +49,14 @@ fetchbyte(struct proc *p, unsigned addr, char* c)
|
|||
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;
|
||||
|
@ -70,7 +70,7 @@ sys_pipe(void)
|
|||
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;
|
||||
|
@ -105,7 +105,7 @@ int
|
|||
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)
|
||||
|
@ -124,7 +124,7 @@ int
|
|||
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)
|
||||
|
@ -209,7 +209,7 @@ sys_cons_puts(void)
|
|||
{
|
||||
char buf[256];
|
||||
int i;
|
||||
unsigned addr;
|
||||
uint addr;
|
||||
struct proc *cp = curproc[cpu()];
|
||||
|
||||
if(fetcharg(0, &addr) < 0)
|
||||
|
@ -251,7 +251,7 @@ int
|
|||
sys_panic(void)
|
||||
{
|
||||
struct proc *p = curproc[cpu()];
|
||||
unsigned int addr;
|
||||
uint addr;
|
||||
|
||||
if(fetcharg(0, &addr) < 0)
|
||||
return -1;
|
||||
|
|
6
trap.c
6
trap.c
|
@ -8,7 +8,7 @@
|
|||
#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);
|
||||
|
@ -56,8 +56,8 @@ trap(struct Trapframe *tf)
|
|||
}
|
||||
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();
|
||||
|
|
Loading…
Reference in a new issue