spacing fixes: no tabs, 2-space indents (for rtm)
This commit is contained in:
parent
45854caa93
commit
a650c606fe
33 changed files with 913 additions and 905 deletions
1
asm.h
1
asm.h
|
@ -5,6 +5,7 @@
|
||||||
#define SEG_NULLASM \
|
#define SEG_NULLASM \
|
||||||
.word 0, 0; \
|
.word 0, 0; \
|
||||||
.byte 0, 0, 0, 0
|
.byte 0, 0, 0, 0
|
||||||
|
|
||||||
#define SEG_ASM(type,base,lim) \
|
#define SEG_ASM(type,base,lim) \
|
||||||
.word (((lim) >> 12) & 0xffff), ((base) & 0xffff); \
|
.word (((lim) >> 12) & 0xffff), ((base) & 0xffff); \
|
||||||
.byte (((base) >> 16) & 0xff), (0x90 | (type)), \
|
.byte (((base) >> 16) & 0xff), (0x90 | (type)), \
|
||||||
|
|
17
bootasm.S
17
bootasm.S
|
@ -18,7 +18,8 @@
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
.globl start # Entry point
|
.globl start # Entry point
|
||||||
start: .code16 # This runs in real mode
|
start:
|
||||||
|
.code16 # This runs in real mode
|
||||||
cli # Disable interrupts
|
cli # Disable interrupts
|
||||||
cld # String operations increment
|
cld # String operations increment
|
||||||
|
|
||||||
|
@ -39,12 +40,15 @@ start: .code16 # This runs in real mode
|
||||||
#### Obviously this a bit of a drag for us, especially when trying to
|
#### Obviously this a bit of a drag for us, especially when trying to
|
||||||
#### address memory above 1MB. This code undoes this.
|
#### address memory above 1MB. This code undoes this.
|
||||||
|
|
||||||
seta20.1: inb $0x64,%al # Get status
|
seta20.1:
|
||||||
|
inb $0x64,%al # Get status
|
||||||
testb $0x2,%al # Busy?
|
testb $0x2,%al # Busy?
|
||||||
jnz seta20.1 # Yes
|
jnz seta20.1 # Yes
|
||||||
movb $0xd1,%al # Command: Write
|
movb $0xd1,%al # Command: Write
|
||||||
outb %al,$0x64 # output port
|
outb %al,$0x64 # output port
|
||||||
seta20.2: inb $0x64,%al # Get status
|
|
||||||
|
seta20.2:
|
||||||
|
inb $0x64,%al # Get status
|
||||||
testb $0x2,%al # Busy?
|
testb $0x2,%al # Busy?
|
||||||
jnz seta20.2 # Yes
|
jnz seta20.2 # Yes
|
||||||
movb $0xdf,%al # Enable
|
movb $0xdf,%al # Enable
|
||||||
|
@ -60,7 +64,8 @@ seta20.2: inb $0x64,%al # Get status
|
||||||
#### This initial NOP-translation setup is required by the processor
|
#### This initial NOP-translation setup is required by the processor
|
||||||
#### to ensure that the transition to protected mode occurs smoothly.
|
#### to ensure that the transition to protected mode occurs smoothly.
|
||||||
|
|
||||||
real_to_prot: cli # Mandatory since we dont set up an IDT
|
real_to_prot:
|
||||||
|
cli # Mandatory since we dont set up an IDT
|
||||||
lgdt gdtdesc # load GDT -- mandatory in protected mode
|
lgdt gdtdesc # load GDT -- mandatory in protected mode
|
||||||
movl %cr0, %eax # turn on protected mode
|
movl %cr0, %eax # turn on protected mode
|
||||||
orl $CR0_PE_ON, %eax #
|
orl $CR0_PE_ON, %eax #
|
||||||
|
@ -83,7 +88,9 @@ protcseg:
|
||||||
|
|
||||||
call cmain # finish the boot load from C.
|
call cmain # finish the boot load from C.
|
||||||
# cmain() should not return
|
# cmain() should not return
|
||||||
spin: jmp spin # ..but in case it does, spin
|
spin:
|
||||||
|
jmp spin # ..but in case it does, spin
|
||||||
|
|
||||||
|
|
||||||
.p2align 2 # force 4 byte alignment
|
.p2align 2 # force 4 byte alignment
|
||||||
gdt:
|
gdt:
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
.set CR0_PE_ON,0x1 # protected mode enable flag
|
.set CR0_PE_ON,0x1 # protected mode enable flag
|
||||||
|
|
||||||
.globl start
|
.globl start
|
||||||
start: .code16 # This runs in real mode
|
start:
|
||||||
|
.code16 # This runs in real mode
|
||||||
cli # Disable interrupts
|
cli # Disable interrupts
|
||||||
cld # String operations increment
|
cld # String operations increment
|
||||||
|
|
||||||
|
|
1
ide.c
1
ide.c
|
@ -23,6 +23,7 @@ struct ide_request {
|
||||||
uint nsecs;
|
uint nsecs;
|
||||||
uint read;
|
uint read;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ide_request request[NREQUEST];
|
struct ide_request request[NREQUEST];
|
||||||
int head, tail;
|
int head, tail;
|
||||||
struct spinlock ide_lock;
|
struct spinlock ide_lock;
|
||||||
|
|
2
mkfs.c
2
mkfs.c
|
@ -81,7 +81,7 @@ main(int argc, char *argv[])
|
||||||
usedblocks = ninodes / IPB + 3 + bitblocks;
|
usedblocks = ninodes / IPB + 3 + bitblocks;
|
||||||
freeblock = usedblocks;
|
freeblock = usedblocks;
|
||||||
|
|
||||||
printf ("used %d (bit %d ninode %d) free %d total %d\n", usedblocks,
|
printf("used %d (bit %d ninode %d) free %d total %d\n", usedblocks,
|
||||||
bitblocks, ninodes/IPB + 1, freeblock, nblocks+usedblocks);
|
bitblocks, ninodes/IPB + 1, freeblock, nblocks+usedblocks);
|
||||||
|
|
||||||
assert (nblocks + usedblocks == size);
|
assert (nblocks + usedblocks == size);
|
||||||
|
|
2
setjmp.S
2
setjmp.S
|
@ -33,5 +33,3 @@ longjmp:
|
||||||
movl $1, %eax /* return value (appears to come from setjmp!) */
|
movl $1, %eax /* return value (appears to come from setjmp!) */
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.text
|
.text
|
||||||
.globl trap
|
.globl trap
|
||||||
.globl trapret1
|
.globl trapret1
|
||||||
|
|
||||||
|
|
6
ulib.c
6
ulib.c
|
@ -37,7 +37,7 @@ strlen(char *s)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void*
|
||||||
memset(void *dst, int c, unsigned int n)
|
memset(void *dst, int c, unsigned int n)
|
||||||
{
|
{
|
||||||
char *d = (char *) dst;
|
char *d = (char *) dst;
|
||||||
|
@ -48,7 +48,7 @@ memset(void *dst, int c, unsigned int n)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char*
|
||||||
strchr(const char *s, char c)
|
strchr(const char *s, char c)
|
||||||
{
|
{
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
|
@ -57,7 +57,7 @@ strchr(const char *s, char c)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char*
|
||||||
gets(char *buf, int max)
|
gets(char *buf, int max)
|
||||||
{
|
{
|
||||||
int i = 0, cc;
|
int i = 0, cc;
|
||||||
|
|
|
@ -13,10 +13,10 @@ for(my $i = 0; $i < 256; $i++){
|
||||||
print ".globl vector$i\n";
|
print ".globl vector$i\n";
|
||||||
print "vector$i:\n";
|
print "vector$i:\n";
|
||||||
if(($i < 8 || $i > 14) && $i != 17){
|
if(($i < 8 || $i > 14) && $i != 17){
|
||||||
print "\tpushl \$0\n";
|
print " pushl \$0\n";
|
||||||
}
|
}
|
||||||
print "\tpushl \$$i\n";
|
print " pushl \$$i\n";
|
||||||
print "\tjmp alltraps\n";
|
print " jmp alltraps\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n/* vector table */\n";
|
print "\n/* vector table */\n";
|
||||||
|
@ -24,5 +24,5 @@ print ".data\n";
|
||||||
print ".globl vectors\n";
|
print ".globl vectors\n";
|
||||||
print "vectors:\n";
|
print "vectors:\n";
|
||||||
for(my $i = 0; $i < 256; $i++){
|
for(my $i = 0; $i < 256; $i++){
|
||||||
print "\t.long vector$i\n";
|
print " .long vector$i\n";
|
||||||
}
|
}
|
||||||
|
|
14
x86.h
14
x86.h
|
@ -88,9 +88,9 @@ static __inline void
|
||||||
cpuid(uint info, uint *eaxp, uint *ebxp, uint *ecxp, uint *edxp)
|
cpuid(uint info, uint *eaxp, uint *ebxp, uint *ecxp, uint *edxp)
|
||||||
{
|
{
|
||||||
uint eax, ebx, ecx, edx;
|
uint eax, ebx, ecx, edx;
|
||||||
asm volatile("cpuid"
|
asm volatile("cpuid" :
|
||||||
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
"=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) :
|
||||||
: "a" (info));
|
"a" (info));
|
||||||
if (eaxp)
|
if (eaxp)
|
||||||
*eaxp = eax;
|
*eaxp = eax;
|
||||||
if (ebxp)
|
if (ebxp)
|
||||||
|
@ -105,10 +105,10 @@ static __inline uint
|
||||||
cmpxchg(uint oldval, uint newval, volatile uint* lock_addr)
|
cmpxchg(uint oldval, uint newval, volatile uint* lock_addr)
|
||||||
{
|
{
|
||||||
uint result;
|
uint result;
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__("lock; cmpxchgl %2, %0" :
|
||||||
"lock; cmpxchgl %2, %0"
|
"+m" (*lock_addr), "=a" (result) :
|
||||||
:"+m" (*lock_addr), "=a" (result) : "r"(newval), "1"(oldval) : "cc"
|
"r"(newval), "1"(oldval) :
|
||||||
);
|
"cc");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue