Skip to content

Commit

Permalink
5.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StjepanBM1 committed Nov 18, 2023
1 parent 45ab08f commit c9b1a34
Show file tree
Hide file tree
Showing 69 changed files with 677 additions and 4,321 deletions.
83 changes: 43 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@

override FLP = os1.img
override ISO = os1.iso
override BINS := $(shell find ./ -type f -name '*.bin')
override FD_IMG := img/disk.img
override CD_IMG := img/disk.iso

.PHONY:all
all: load kern binary disk run
override OS_BIN := bin/os.sys

#
# Builds the LOAD (bootloader)
load:
make -C boot
override BOOT_FILE := bin/boot.sys
override KERN_FILE := bin/kernel.sys

#
# Builds the main kernel (called Copland)
kern:
make -C kernel
.PHONY: all boot kernel
all: boot kernel disk run

#
# Create a system binary by combining nload.bin & kernel.bin
binary:
cat bin/boot.bin bin/kernel.bin > bin/os1.bin
#
# Creates a low density 360 KiB
disk: load kernel binary
dd if=/dev/zero of=img/$(FLP) bs=512 count=720
dd if=bin/os1.bin of=img/$(FLP) conv=notrunc
boot:
make -f boot/boot.mk

kernel:
make -f kernel/kernel.mk

#
# Create high density 1.44M floppy image (needed for CD-ISO)
144img:
dd if=/dev/zero of=img/$(FLP) bs=512 count=2880
dd if=bin/os1.bin of=img/$(FLP) conv=notrunc
# Double Density 3.5" 720KiB disks
#
disk:
dd if=/dev/zero of=$(FD_IMG) bs=512 count=1440
dd if=$(BOOT_FILE) of=$(FD_IMG) bs=512 count=1 conv=notrunc
dd if=$(KERN_FILE) of=$(FD_IMG) bs=512 seek=1 conv=notrunc

#
# Creates an ISO image
cdiso: 144img
mkisofs -quiet -V 'os1-ar-510' -input-charset iso8859-1 -o img/$(ISO) -b $(FLP) img/
# CD ISO - uses high density 1.44MB disk image
#
# Runs the os1.img in QEMU
run: disk
qemu-system-i386 -fda img/$(FLP)
cdrom: base
dd if=/dev/zero of=$(FD_IMG) bs=512 count=2880
dd if=$(BOOT_FILE) of=$(FD_IMG) bs=512 count=1 conv=notrunc
dd if=$(KERN_FILE) of=$(FD_IMG) bs=512 seek=1 conv=notrunc

#
# Run the CD-ISO image (os1.iso) - QEMU
runcd: cdiso
qemu-system-i386 -cdrom img/$(ISO)
mkisofs -quiet -V 'honolulu' \
-input-charset iso8859-1 \
-o img/disk.iso \
-b disk.img \
img

run:
qemu-system-i386 -fda $(FD_IMG)

run-cd: cdrom
qemu-system-i386 -cdrom $(CD_IMG)

utils:
make -f utils/utils.mk

.PHONY: clean
clean:
make -C boot clean
make -C kernel clean
make -C pinboard clean
rm $(BINS) img/$(FLP) img/$(ISO)
make -f boot/boot.mk clean
make -f kernel/kernel.mk clean
make -f utils/utils.mk clean

rm $(FD_IMG)
rm $(CD_IMG)
7 changes: 5 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Operating System/1 Average Release 5.2.1
Operating System/1 Average Release 5.3.0
================================================

Changes:
- trigger kernel panic from MP
- partial working BBFS driver (read only)
for more info check kernel/fs/bbfs/bbfs.txt

- changes to the Makefiles
Binary file added bin/boot.sys
Binary file not shown.
Binary file added bin/kernel.sys
Binary file not shown.
Binary file added bin/os.sys
Binary file not shown.
8 changes: 4 additions & 4 deletions boot/Makefile → boot/boot.mk
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

# Change as you like but keep it x86 compatable.
ARCH=i386-elf

AS=$(ARCH)-as
LD=$(ARCH)-ld

override BIN := ../bin/boot.bin
override ASM := $(shell find ./ -type f -name '*.S')
override BIN := ./bin/boot.sys
override ASM := $(shell find ./boot -type f -name '*.S')
override OBJ := $(ASM:.S=.o)

.PHONY: all
all: $(BIN)

$(BIN): $(OBJ)
$(LD) -Tx86.ld $(OBJ) -o $@
$(LD) -Tboot/x86.ld $(OBJ) -o $@

%.o: %.S
$(AS) $< -o $@

.PHONY: clean
clean:
rm $(OBJ)
rm $(BIN)
56 changes: 9 additions & 47 deletions boot/libx86.S
Original file line number Diff line number Diff line change
@@ -1,55 +1,17 @@

.code16
.global read_disk
.global _print
.section .text
.extern STAGE2
.global _dev
_print:
lodsb

read_disk:
clc
incb (trys)
or %al, %al
jz .p_done

mov $0x02, %ah # Read disk arg. (ah = 0x02)
mov $0x40, %al # Number of sectors to read (64)
mov $0x7e00,%bx # Buffer address (2nd sector)
mov $0x00, %ch # Track / Cylinder number
mov $0x02, %cl # Sector number
mov $0x00, %dh # Head number
movb (_dev), %dl # Disk drive (0 - drive A; 1 - drive B)

int $0x13 # Disk interrupt (0x13)

jc disk_error # If clear flag is set jump to disk_error

ret # Return

disk_info:

disk_error:
clc
cmpb $3, (trys) # If num of tries is less than 3
jl read_disk # jump to read_disk

mov $0x03, %ax # Clear the screen
mov $0x0e, %ah
int $0x10

mov $0x13, %ah # Value 0x13 (print str.)
mov $0x01, %al # String type
mov $0x00, %bh # Video page num.
mov $0x0c, %bl # Attribute (L. Red on Black)
mov $38, %cx # String len. = 38 chars.
mov $0x00, %dh # Row 1
mov $0x00, %dl # Column 0
mov $_err0, %bp # String to print
int $0x10 # Call interrupt

cli
hlt

.section .rodata
_err0: .asciz "/!\\ Disk read error, system halted /!\\"
jmp _print

.section .data
# Disk read
trys: .byte 0
_dev: .byte 0
.p_done:
ret
115 changes: 89 additions & 26 deletions boot/x86.S
Original file line number Diff line number Diff line change
@@ -1,38 +1,101 @@

.code16
.global _stage1
.section .text.s1
.set STAGE2, 0x7e00
.global STAGE2
.extern _dev
.section .text
.global _entry

_stage1: # Bootloader entry point
.extern _printk

/*
* Entry point (for the linker)
*/
_entry:
jmp _start # Jump over the BBFS
nop

movb %dl, _dev # Boot device value
/*
* Bad Block File System
* Parameters
*
* as defined in BBFS specification
*/
_disk_label: .asciz "OS1 BOOT" # Disk label, 8 bytes
_block_size: .byte 5 # size of the blocks
_reserved: .word 0 # 2 bytes of reserve
_bootable: .byte 1 # Bootable: 1-yes, 0-no
_file_sys: .asciz "BBFS V01" # File system str. 8 chars.

xor %ax, %ax
mov %ax, %ds
mov %ax, %ss
mov $_stage1,%sp
cld
/*
* Main bootloader function
*/
_start:
movb %dl, _bd # Save boot device num.

mov $0x03, %ax
int $0x10

/* First part of the boot msg. */
mov $0x03, %ax # Clear the screen
# Set pallete register
mov $0x1003,%ax
mov $0x00, %bl
int $0x10

mov $0x13, %ah # Value 0x13 (print str.)
mov $0x01, %al # String type
mov $0x00, %bh # Video page num.
mov $0x0f, %bl # Attribute (White on Black)
mov $0x04, %cx # String len. = 4 chars.
mov $0x00, %dh # Row 0
mov $0x00, %dl # Column 0
mov $_msg0, %bp # String to print
int $0x10 # Call interrupt
# Set up the font
mov $0x11, %ah
mov $0x11, %al
int $0x10

#
# Stack setup
#
cli
mov $0x9000,%ax
mov %ax, %ss
mov $0xF800,%sp
sti

# Print boot msg.
mov $_sm, %si
call _print

call read_disk
/*
* Read kernel func.
*
* reads 128 sectors.
*/
_disk_read:

xor %ax, %ax
mov %ax, %es

mov $0x02, %ah
mov $0x40, %al
mov $0x7e00,%bx
mov $0x00, %ch
mov $0x02, %cl
mov $0x00, %dh
movb (_bd), %dl

int $0x13

jc _disk_error

mov $_ok, %si
call _print

jmp 0x7e00

.section .rodata # Read-only data
_msg0: .asciz "\xDB\xDB\xDB " # Boot message (1/2).
_disk_error:
mov $_er, %si
call _print

_end:
cli
hlt

.section .rodata
_sm: .asciz "Booting..."
_ok: .asciz "\r\nLoaded."
_pc: .asciz "\r\nPassing control to the kernel...\r\n"
_er: .asciz "\r\nDisk read error!"

.section .data
_bd: .byte 0
11 changes: 6 additions & 5 deletions boot/x86.ld
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

OUTPUT_FORMAT(binary);
ENTRY(_stage1);
ENTRY(_entry);

SECTIONS
{
. = 0x7c00;
.text : SUBALIGN(0)
{
*(.text.s1);
*(.text)
}

Expand All @@ -20,13 +20,14 @@ SECTIONS
*(.data)
}

.sig : AT(0x7DFE)
.sig : AT(0x7dfe)
{
SHORT(0xaa55);
}

/DISCARD/ : {
/DISCARD/ : {
*(.comment);
*(.note*);
*(.note*)
}

}
3 changes: 0 additions & 3 deletions dir_strut.sh

This file was deleted.

3 changes: 3 additions & 0 deletions dirs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

mkdir bin
mkdir img
Binary file added img/disk.img
Binary file not shown.
23 changes: 0 additions & 23 deletions kernel/Makefile

This file was deleted.

4 changes: 0 additions & 4 deletions kernel/README.txt

This file was deleted.

Loading

0 comments on commit c9b1a34

Please sign in to comment.