Skip to content

Commit

Permalink
standardize various * conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Sep 6, 2006
1 parent 03b6376 commit 9e9bcaf
Show file tree
Hide file tree
Showing 43 changed files with 503 additions and 503 deletions.
10 changes: 5 additions & 5 deletions bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ binit(void)
}
}

struct buf *
struct buf*
getblk(uint dev, uint sector)
{
struct buf *b;
Expand Down Expand Up @@ -67,7 +67,7 @@ getblk(uint dev, uint sector)
}
}

struct buf *
struct buf*
bread(uint dev, uint sector)
{
void *c;
Expand All @@ -80,7 +80,7 @@ bread(uint dev, uint sector)

acquire(&ide_lock);
c = ide_start_rw(dev & 0xff, sector, b->data, 1, 1);
sleep (c, &ide_lock);
sleep(c, &ide_lock);
ide_finish(c);
b->flags |= B_VALID;
release(&ide_lock);
Expand All @@ -96,7 +96,7 @@ bwrite(struct buf *b, uint sector)

acquire(&ide_lock);
c = ide_start_rw(b->dev & 0xff, sector, b->data, 1, 0);
sleep (c, &ide_lock);
sleep(c, &ide_lock);
ide_finish(c);
b->flags |= B_VALID;
release(&ide_lock);
Expand All @@ -107,7 +107,7 @@ brelse(struct buf *b)
{
if((b->flags & B_BUSY) == 0)
panic("brelse");

acquire(&buf_table_lock);

b->next->prev = b->prev;
Expand Down
30 changes: 15 additions & 15 deletions bootasm.S
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#include "asm.h"

.set PROT_MODE_CSEG,0x8 # code segment selector
.set PROT_MODE_DSEG,0x10 # data segment selector
.set CR0_PE_ON,0x1 # protected mode enable flag

###################################################################################
# ENTRY POINT
# ENTRY POINT
# This code should be stored in the first sector of the hard disk.
# After the BIOS initializes the hardware on startup or system reset,
# it loads this code at physical address 0x7c00 - 0x7d00 (512 bytes).
# Then the BIOS jumps to the beginning of it, address 0x7c00,
# while running in 16-bit real-mode (8086 compatibility mode).
# The Code Segment register (CS) is initially zero on entry.
#
#
# This code switches into 32-bit protected mode so that all of
# memory can accessed, then calls into C.
###################################################################################
.globl start # Entry point

.globl start # Entry point
start:
.code16 # This runs in real mode
cli # Disable interrupts
Expand All @@ -31,15 +31,15 @@ start:

# Set up the stack pointer, growing downward from 0x7c00.
movw $start,%sp # Stack Pointer

#### Enable A20:
#### For fascinating historical reasons (related to the fact that
#### the earliest 8086-based PCs could only address 1MB of physical memory
#### and subsequent 80286-based PCs wanted to retain maximum compatibility),
#### physical address line 20 is tied to low when the machine boots.
#### Obviously this a bit of a drag for us, especially when trying to
#### address memory above 1MB. This code undoes this.

seta20.1:
inb $0x64,%al # Get status
testb $0x2,%al # Busy?
Expand All @@ -54,7 +54,7 @@ seta20.2:
movb $0xdf,%al # Enable
outb %al,$0x60 # A20

#### Switch from real to protected mode
#### Switch from real to protected mode
#### The descriptors in our GDT allow all physical memory to be accessed.
#### Furthermore, the descriptors have base addresses of 0, so that the
#### segment translation is a NOP, ie. virtual addresses are identical to
Expand All @@ -63,21 +63,21 @@ seta20.2:
#### that it is running directly on physical memory with no translation.
#### This initial NOP-translation setup is required by the processor
#### to ensure that the transition to protected mode occurs smoothly.

real_to_prot:
cli # Mandatory since we dont set up an IDT
lgdt gdtdesc # load GDT -- mandatory in protected mode
movl %cr0, %eax # turn on protected mode
orl $CR0_PE_ON, %eax #
movl %eax, %cr0 #
orl $CR0_PE_ON, %eax #
movl %eax, %cr0 #
### CPU magic: jump to relocation, flush prefetch queue, and reload %cs
### Has the effect of just jmp to the next instruction, but simultaneous
### loads CS with $PROT_MODE_CSEG.
ljmp $PROT_MODE_CSEG, $protcseg

#### we are in 32-bit protected mode (hence the .code32)
.code32
protcseg:
protcseg:
# Set up the protected-mode data segment registers
movw $PROT_MODE_DSEG, %ax # Our data segment selector
movw %ax, %ds # -> DS: Data Segment
Expand All @@ -97,7 +97,7 @@ gdt:
SEG_NULLASM # null seg
SEG_ASM(STA_X|STA_R, 0x0, 0xffffffff) # code seg
SEG_ASM(STA_W, 0x0, 0xffffffff) # data seg

gdtdesc:
.word 0x17 # sizeof(gdt) - 1
.long gdt # address gdt
24 changes: 12 additions & 12 deletions bootmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
* DISK LAYOUT
* * This program(boot.S and main.c) is the bootloader. It should
* be stored in the first sector of the disk.
*
*
* * The 2nd sector onward holds the kernel image.
*
*
* * The kernel image must be in ELF format.
*
* BOOT UP STEPS
* BOOT UP STEPS
* * when the CPU boots it loads the BIOS into memory and executes it
*
* * the BIOS intializes devices, sets of the interrupt routines, and
* reads the first sector of the boot device(e.g., hard-drive)
* reads the first sector of the boot device(e.g., hard-drive)
* into memory and jumps to it.
*
* * Assuming this boot loader is stored in the first sector of the
Expand All @@ -31,7 +31,7 @@
**********************************************************************/

#define SECTSIZE 512
#define ELFHDR ((struct elfhdr *) 0x10000) // scratch space
#define ELFHDR ((struct elfhdr*) 0x10000) // scratch space

void readsect(void*, uint);
void readseg(uint, uint, uint);
Expand All @@ -45,18 +45,18 @@ cmain(void)
readseg((uint) ELFHDR, SECTSIZE*8, 0);

// is this a valid ELF?
if (ELFHDR->magic != ELF_MAGIC)
if(ELFHDR->magic != ELF_MAGIC)
goto bad;

// load each program segment (ignores ph flags)
ph = (struct proghdr *) ((uchar *) ELFHDR + ELFHDR->phoff);
ph = (struct proghdr*) ((uchar*) ELFHDR + ELFHDR->phoff);
eph = ph + ELFHDR->phnum;
for (; ph < eph; ph++)
for(; ph < eph; ph++)
readseg(ph->va, ph->memsz, ph->offset);

// call the entry point from the ELF header
// note: does not return!
((void (*)(void)) (ELFHDR->entry & 0xFFFFFF))();
((void(*)(void)) (ELFHDR->entry & 0xFFFFFF))();

bad:
outw(0x8A00, 0x8A00);
Expand All @@ -74,7 +74,7 @@ readseg(uint va, uint count, uint offset)

va &= 0xFFFFFF;
end_va = va + count;

// round down to sector boundary
va &= ~(SECTSIZE - 1);

Expand All @@ -84,7 +84,7 @@ readseg(uint va, uint count, uint offset)
// If this is too slow, we could read lots of sectors at a time.
// We'd write more to memory than asked, but it doesn't matter --
// we load in increasing order.
while (va < end_va) {
while(va < end_va) {
readsect((uchar*) va, offset);
va += SECTSIZE;
offset++;
Expand All @@ -95,7 +95,7 @@ void
waitdisk(void)
{
// wait for disk reaady
while ((inb(0x1F7) & 0xC0) != 0x40)
while((inb(0x1F7) & 0xC0) != 0x40)
/* do nothing */;
}

Expand Down
22 changes: 11 additions & 11 deletions bootother.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "asm.h"

/*
* Start an Application Processor. This must be placed on a 4KB boundary
* somewhere in the 1st MB of conventional memory (APBOOTSTRAP). However,
Expand All @@ -13,7 +13,7 @@
* mp.c causes each non-boot CPU in turn to jump to start.
* mp.c puts the correct %esp in start-4, and the place to jump
* to in start-8.
*
*
*/

.set PROT_MODE_CSEG,0x8 # code segment selector
Expand All @@ -34,8 +34,8 @@ start:

# Set up the stack pointer, growing downward from 0x7000-8.
movw $start-8,%sp # Stack Pointer
#### Switch from real to protected mode

#### Switch from real to protected mode
#### The descriptors in our GDT allow all physical memory to be accessed.
#### Furthermore, the descriptors have base addresses of 0, so that the
#### segment translation is a NOP, ie. virtual addresses are identical to
Expand All @@ -44,19 +44,19 @@ start:
#### that it is running directly on physical memory with no translation.
#### This initial NOP-translation setup is required by the processor
#### to ensure that the transition to protected mode occurs smoothly.

lgdt gdtdesc # load GDT -- mandatory in protected mode
movl %cr0, %eax # turn on protected mode
orl $CR0_PE_ON, %eax #
movl %eax, %cr0 #
orl $CR0_PE_ON, %eax #
movl %eax, %cr0 #
### CPU magic: jump to relocation, flush prefetch queue, and reload %cs
### Has the effect of just jmp to the next instruction, but simultaneous
### loads CS with $PROT_MODE_CSEG.
ljmp $PROT_MODE_CSEG, $protcseg

#### we are in 32-bit protected mode (hence the .code32)
.code32
protcseg:
protcseg:
# Set up the protected-mode data segment registers
movw $PROT_MODE_DSEG, %ax # Our data segment selector
movw %ax, %ds # -> DS: Data Segment
Expand All @@ -67,14 +67,14 @@ protcseg:

movl start-8, %eax
movl start-4, %esp
jmp *%eax
jmp *%eax

.p2align 2 # force 4 byte alignment
gdt:
SEG_NULLASM # null seg
SEG_ASM(STA_X|STA_R, 0x0, 0xffffffff) # code seg
SEG_ASM(STA_W, 0x0, 0xffffffff) # data seg

gdtdesc:
.word 0x17 # sizeof(gdt) - 1
.long gdt # address gdt
2 changes: 1 addition & 1 deletion cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ main(int argc, char *argv[])
{
int fd, i;

if (argc <= 1) {
if(argc <= 1) {
rfile(0);
} else {
for(i = 1; i < argc; i++){
Expand Down
Loading

0 comments on commit 9e9bcaf

Please sign in to comment.