Permalink
Browse files

initial project structure

  • Loading branch information...
igorekbsu
igorekbsu committed Jan 18, 2012
0 parents commit 7a03abb348b18d64f158978433011bde510ce730
Showing with 114 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +12 −0 bochsrc.txt
  3. BIN floppy.flp
  4. +8 −0 run_bochs.sh
  5. +85 −0 src/boot.asm
  6. +6 −0 update_image.sh
@@ -0,0 +1,3 @@
+*.o
+*.bin
+*.out
@@ -0,0 +1,12 @@
+megs: 32
+romimage: file=/usr/share/bochs/BIOS-bochs-latest
+vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest
+floppya: 1_44=/dev/loop0, status=inserted
+boot: a
+log: bochsout.txt
+mouse: enabled=0
+clock: sync=realtime
+cpu: ips=500000
+# logging and reporting -----------------------------------------------
+error: action=report
+info: action=report
Binary file not shown.
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# run_bochs.sh
+# mounts the correct loopback device, runs bochs, then unmounts.
+
+sudo /sbin/losetup /dev/loop0 floppy.flp
+sudo bochs -f bochsrc.txt
+sudo /sbin/losetup -d /dev/loop0
@@ -0,0 +1,85 @@
+;*********************************************
+; Boot1.asm
+; - A Simple Bootloader
+;
+; Operating Systems Development Tutorial
+;*********************************************
+
+bits 16 ; We are still in 16 bit Real Mode
+
+org 0x7c00 ; We are loaded by BIOS at 0x7C00
+
+start: jmp loader ; jump over OEM block
+
+;*************************************************;
+; OEM Parameter block
+;*************************************************;
+
+; Error Fix 2 - Removing the ugly TIMES directive -------------------------------------
+
+;; TIMES 0Bh-$+start DB 0 ; The OEM Parameter Block is exactally 3 bytes
+ ; from where we are loaded at. This fills in those
+ ; 3 bytes, along with 8 more. Why?
+
+bpbOEM db "My OS " ; This member must be exactally 8 bytes. It is just
+ ; the name of your OS :) Everything else remains the same.
+
+bpbBytesPerSector: DW 512
+bpbSectorsPerCluster: DB 1
+bpbReservedSectors: DW 1
+bpbNumberOfFATs: DB 2
+bpbRootEntries: DW 224
+bpbTotalSectors: DW 2880
+bpbMedia: DB 0xF0
+bpbSectorsPerFAT: DW 9
+bpbSectorsPerTrack: DW 18
+bpbHeadsPerCylinder: DW 2
+bpbHiddenSectors: DD 0
+bpbTotalSectorsBig: DD 0
+bsDriveNumber: DB 0
+bsUnused: DB 0
+bsExtBootSignature: DB 0x29
+bsSerialNumber: DD 0xa0a1a2a3
+bsVolumeLabel: DB "MOS FLOPPY "
+bsFileSystem: DB "FAT12 "
+
+msg db "Welcome to simpleos!", 0 ; the string to print
+
+;***************************************
+; Prints a string
+; DS=>SI: 0 terminated string
+;***************************************
+
+Print:
+ lodsb ; load next byte from string from SI to AL
+ or al, al ; Does AL=0?
+ jz PrintDone ; Yep, null terminator found-bail out
+ mov ah, 0eh ; Nope-Print the character
+ int 10h
+ jmp Print ; Repeat until null terminator found
+PrintDone:
+ ret ; we are done, so return
+
+;*************************************************;
+; Bootloader Entry Point
+;*************************************************;
+
+loader:
+
+ xor ax, ax ; Setup segments to insure they are 0. Remember that
+ mov ds, ax ; we have ORG 0x7c00. This means all addresses are based
+ mov es, ax ; from 0x7c00:0. Because the data segments are within the same
+ ; code segment, null em.
+
+ mov si, msg ; our message to print
+ call Print ; call our print function
+
+ xor ax, ax ; clear ax
+ int 0x12 ; get the amount of KB from the BIOS
+
+ cli ; Clear all Interrupts
+ hlt ; halt the system
+
+times 510 - ($-$$) db 0 ; We have to be 512 bytes. Clear the rest of the bytes with 0
+
+dw 0xAA55 ; Boot Signiture
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+cd src
+nasm -f bin -o boot.bin boot.asm
+cd ..
+dd status=noxfer conv=notrunc if=src/boot.bin of=floppy.flp

0 comments on commit 7a03abb

Please sign in to comment.