Skip to content

Commit

Permalink
Fix syntax for some code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Aug 27, 2014
1 parent ec200d1 commit b9c3339
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
14 changes: 7 additions & 7 deletions Chapter-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This boot process also initializes some of our C++ runtime, it will be described

Multiboot header structure:

```
```cpp
struct multiboot_info {
u32 flags;
u32 low_mem;
Expand Down Expand Up @@ -82,7 +82,7 @@ qemu-img create c.img 2M
We need now to partition the disk using fdisk:
```
```bash
fdisk ./c.img
# Switch to Expert commands
Expand Down Expand Up @@ -132,27 +132,27 @@ We need now to attach the created partition to the loop-device (which allows a f

Using ```fdisk -l -u c.img```, you get: 63 * 512 = 32256.

```
```bash
losetup -o 32256 /dev/loop1 ./c.img
```

We create a EXT2 filesystem on this new device using:

```
```bash
mke2fs /dev/loop1
```

We copy our files on a mounted disk:

```
```bash
mount /dev/loop1 /mnt/
cp -R bootdisk/* /mnt/
umount /mnt/
```

Install GRUB on the disk:

```
```bash
grub --device-map=/dev/null << EOF
device (hd0) ./c.img
geometry (hd0) 4 16 63
Expand All @@ -164,7 +164,7 @@ EOF

And finally we detach the loop device:

```
```bash
losetup -d /dev/loop1
```

Expand Down
12 changes: 6 additions & 6 deletions Chapter-5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ void Io::putc(char c){
unsigned char *video;
video = (unsigned char *) (real_screen+ 2 * x + 160 * y);
// newline
if (c == '\n') {
if (c == '\n') {
x = 0;
y++;
// back space
} else if (c == '\b') {
} else if (c == '\b') {
if (x) {
*(video + 1) = 0x0;
x--;
}
// horizontal tab
} else if (c == '\t') {
} else if (c == '\t') {
x = x + 8 - (x % 8);
// carriage return
} else if (c == '\r') {
} else if (c == '\r') {
x = 0;
} else {
} else {
*video = c;
*(video + 1) = kattr;

Expand Down Expand Up @@ -144,7 +144,7 @@ void Io::print(const char *s, ...){
print("0x%s", buf);
} else if (c == 's') {
print((char *) va_arg(ap, int));
}
}
} else
putc(c);
}
Expand Down
54 changes: 27 additions & 27 deletions Chapter-7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ Here is a table of common interrupts (Maskable hardware interrupt are called IRQ

| IRQ | Description |
|:-----:| -------------------------- |
| 0 | Programmable Interrupt Timer Interrupt |
| 1 | Keyboard Interrupt |
| 2 | Cascade (used internally by the two PICs. never raised) |
| 3 | COM2 (if enabled) |
| 4 | COM1 (if enabled) |
| 5 | LPT2 (if enabled) |
| 6 | Floppy Disk |
| 7 | LPT1 |
| 8 | CMOS real-time clock (if enabled) |
| 9 | Free for peripherals / legacy SCSI / NIC |
| 10 | Free for peripherals / SCSI / NIC |
| 11 | Free for peripherals / SCSI / NIC |
| 12 | PS2 Mouse |
| 13 | FPU / Coprocessor / Inter-processor |
| 14 | Primary ATA Hard Disk |
| 0 | Programmable Interrupt Timer Interrupt |
| 1 | Keyboard Interrupt |
| 2 | Cascade (used internally by the two PICs. never raised) |
| 3 | COM2 (if enabled) |
| 4 | COM1 (if enabled) |
| 5 | LPT2 (if enabled) |
| 6 | Floppy Disk |
| 7 | LPT1 |
| 8 | CMOS real-time clock (if enabled) |
| 9 | Free for peripherals / legacy SCSI / NIC |
| 10 | Free for peripherals / SCSI / NIC |
| 11 | Free for peripherals / SCSI / NIC |
| 12 | PS2 Mouse |
| 13 | FPU / Coprocessor / Inter-processor |
| 14 | Primary ATA Hard Disk |
| 15 | Secondary ATA Hard Disk |

#### How to initialize the interrupts?
Expand Down Expand Up @@ -101,23 +101,23 @@ void init_idt(void)
{
/* Init irq */
int i;
for (i = 0; i < IDTSIZE; i++)
init_idt_desc(0x08, (u32)_asm_schedule, INTGATE, &kidt[i]); //
for (i = 0; i < IDTSIZE; i++)
init_idt_desc(0x08, (u32)_asm_schedule, INTGATE, &kidt[i]); //

/* Vectors 0 -> 31 are for exceptions */
init_idt_desc(0x08, (u32) _asm_exc_GP, INTGATE, &kidt[13]); /* #GP */
init_idt_desc(0x08, (u32) _asm_exc_PF, INTGATE, &kidt[14]); /* #PF */

init_idt_desc(0x08, (u32) _asm_schedule, INTGATE, &kidt[32]);
init_idt_desc(0x08, (u32) _asm_int_1, INTGATE, &kidt[33]);

init_idt_desc(0x08, (u32) _asm_syscalls, TRAPGATE, &kidt[48]);
init_idt_desc(0x08, (u32) _asm_syscalls, TRAPGATE, &kidt[128]); //48

kidtr.limite = IDTSIZE * 8;
kidtr.base = IDTBASE;


/* Copy the IDT to the memory */
memcpy((char *) kidtr.base, (char *) kidt, kidtr.limite);

Expand Down Expand Up @@ -175,7 +175,7 @@ The registries have to be configured in order.

**ICW2 (port 0x21 / port 0xA1)**
```
|x|x|x|x|x|0|0|0|
|x|x|x|x|x|0|0|0|
| | | | |
+----------------- base address for interrupts vectors
```
Expand Down Expand Up @@ -212,13 +212,13 @@ It is used to define in which mode the controller should work.

You should have noticed that when I'm initializing our IDT segments, I'm using offsets to segment the code in Assembly. The different functions are defined in [x86int.asm](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/arch/x86/x86int.asm) and are of the following scheme:

```
```asm
%macro SAVE_REGS 0
pushad
pushad
push ds
push es
push fs
push gs
push gs
push ebx
mov bx,0x10
mov ds,bx
Expand Down

0 comments on commit b9c3339

Please sign in to comment.