some comment changes
This commit is contained in:
parent
50f8850366
commit
8e1d1ec934
|
@ -5,7 +5,7 @@
|
||||||
.set CR0_PE_ON,0x1 # protected mode enable flag
|
.set CR0_PE_ON,0x1 # protected mode enable flag
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# ENTRY POINT
|
# ENTRY POINT for the bootstrap processor
|
||||||
# This code should be stored in the first sector of the hard disk.
|
# This code should be stored in the first sector of the hard disk.
|
||||||
# After the BIOS initializes the hardware on startup or system reset,
|
# After the BIOS initializes the hardware on startup or system reset,
|
||||||
# it loads this code at physical address 0x7c00 - 0x7d00 (512 bytes).
|
# it loads this code at physical address 0x7c00 - 0x7d00 (512 bytes).
|
||||||
|
|
4
buf.h
4
buf.h
|
@ -6,5 +6,5 @@ struct buf {
|
||||||
struct buf *next;
|
struct buf *next;
|
||||||
uchar data[512];
|
uchar data[512];
|
||||||
};
|
};
|
||||||
#define B_BUSY 0x1
|
#define B_BUSY 0x1 // buffer is locked by some process
|
||||||
#define B_VALID 0x2
|
#define B_VALID 0x2 // buffer contains the data of the sector
|
||||||
|
|
2
fs.c
2
fs.c
|
@ -160,7 +160,7 @@ iget(uint dev, uint inum)
|
||||||
return nip;
|
return nip;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy ip->d, which has changed, to disk.
|
// Copy inode in memory, which has changed, to disk.
|
||||||
// Caller must have locked ip.
|
// Caller must have locked ip.
|
||||||
void
|
void
|
||||||
iupdate(struct inode *ip)
|
iupdate(struct inode *ip)
|
||||||
|
|
4
init.c
4
init.c
|
@ -17,8 +17,8 @@ main(void)
|
||||||
mknod("console", T_DEV, 1, 1);
|
mknod("console", T_DEV, 1, 1);
|
||||||
open("console", O_RDWR);
|
open("console", O_RDWR);
|
||||||
}
|
}
|
||||||
dup(0);
|
dup(0); // stdout
|
||||||
dup(0);
|
dup(0); // stderr
|
||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
|
2
kalloc.c
2
kalloc.c
|
@ -35,7 +35,7 @@ kinit(void)
|
||||||
initlock(&kalloc_lock, "kalloc");
|
initlock(&kalloc_lock, "kalloc");
|
||||||
start = (char*) &end;
|
start = (char*) &end;
|
||||||
start = (char*) (((uint)start + PAGE) & ~(PAGE-1));
|
start = (char*) (((uint)start + PAGE) & ~(PAGE-1));
|
||||||
mem = 256; // assume 256 pages of RAM
|
mem = 256; // assume computer has 256 pages of RAM
|
||||||
cprintf("mem = %d\n", mem * PAGE);
|
cprintf("mem = %d\n", mem * PAGE);
|
||||||
kfree(start, mem * PAGE);
|
kfree(start, mem * PAGE);
|
||||||
}
|
}
|
||||||
|
|
4
main.c
4
main.c
|
@ -15,7 +15,7 @@ extern uchar _binary__init_start[], _binary__init_size[];
|
||||||
|
|
||||||
void process0();
|
void process0();
|
||||||
|
|
||||||
// CPU 0 starts running C code here.
|
// Bootstrap processor starts running C code here.
|
||||||
// This is called main0 not main so that it can have
|
// This is called main0 not main so that it can have
|
||||||
// a void return type. Gcc can't handle functions named
|
// a void return type. Gcc can't handle functions named
|
||||||
// main that don't return int. Really.
|
// main that don't return int. Really.
|
||||||
|
@ -28,7 +28,7 @@ main0(void)
|
||||||
// clear BSS
|
// clear BSS
|
||||||
memset(edata, 0, end - edata);
|
memset(edata, 0, end - edata);
|
||||||
|
|
||||||
// switch to cpu0's cpu stack
|
// switch to bootstrap processor's stack
|
||||||
asm volatile("movl %0, %%esp" : : "r" (cpus[0].mpstack + MPSTACK - 32));
|
asm volatile("movl %0, %%esp" : : "r" (cpus[0].mpstack + MPSTACK - 32));
|
||||||
asm volatile("movl %0, %%ebp" : : "r" (cpus[0].mpstack + MPSTACK));
|
asm volatile("movl %0, %%ebp" : : "r" (cpus[0].mpstack + MPSTACK));
|
||||||
|
|
||||||
|
|
13
spinlock.c
13
spinlock.c
|
@ -51,10 +51,9 @@ acquire(struct spinlock *lock)
|
||||||
while(cmpxchg(0, 1, &lock->locked) == 1)
|
while(cmpxchg(0, 1, &lock->locked) == 1)
|
||||||
;
|
;
|
||||||
|
|
||||||
// Now that lock is acquired, make sure
|
// Serialize instructions: now that lock is acquired, make sure
|
||||||
// we wait for all pending writes from other
|
// we wait for all pending writes from other processors.
|
||||||
// processors.
|
cpuid(0, 0, 0, 0, 0); // memory barrier (see Ch 7 of IA-32 manual, vol 3)
|
||||||
cpuid(0, 0, 0, 0, 0); // memory barrier
|
|
||||||
|
|
||||||
// Record info about lock acquisition for debugging.
|
// Record info about lock acquisition for debugging.
|
||||||
// The +10 is only so that we can tell the difference
|
// The +10 is only so that we can tell the difference
|
||||||
|
@ -74,9 +73,9 @@ release(struct spinlock *lock)
|
||||||
lock->pcs[0] = 0;
|
lock->pcs[0] = 0;
|
||||||
lock->cpu = 0xffffffff;
|
lock->cpu = 0xffffffff;
|
||||||
|
|
||||||
// Before unlocking the lock, make sure to flush
|
// Serialize instructions: before unlocking the lock, make sure
|
||||||
// any pending memory writes from this processor.
|
// to flush any pending memory writes from this processor.
|
||||||
cpuid(0, 0, 0, 0, 0); // memory barrier
|
cpuid(0, 0, 0, 0, 0); // memory barrier (see Ch 7 of IA-32 manual, vol 3)
|
||||||
|
|
||||||
lock->locked = 0;
|
lock->locked = 0;
|
||||||
if(--cpus[cpu()].nlock == 0)
|
if(--cpus[cpu()].nlock == 0)
|
||||||
|
|
Loading…
Reference in a new issue