Skip to content

Commit

Permalink
OS/1 : 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StjepanBM1 committed Jun 1, 2023
1 parent e420756 commit c22917b
Show file tree
Hide file tree
Showing 40 changed files with 469 additions and 2,005 deletions.
Empty file added LICENSE.txt
Empty file.
24 changes: 10 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@

all: boot kern bin disk run
all: bootld kernel disk run

boot:
make -C bootld
bootld:
make -C boot

kern:
make -C kernel
bin:
cat obj/boot16.bin obj/kern16.bin > obj/os1-300.bin
kernel:
make -C dune

disk:
dd if=/dev/zero of=img/disk.img bs=512 count=1440
dd if=obj/os1-300.bin of=img/disk.img conv=notrunc
cat bin/bootld.bin bin/dune.bin > bin/os1.bin
dd if=/dev/zero of=disk.img bs=512 count=360
dd if=bin/os1.bin of=disk.img conv=notrunc

run:
qemu-system-i386 -fda img/disk.img
qemu-system-i386 -fda disk.img

clean:
make -C bootld clean
make -C kernel clean
rm obj/*
rm img/*
rm disk.img bin/*.bin
11 changes: 5 additions & 6 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Operating System One
======================================================
Operating System/1
==================================

Operating System One (shortened to OS/1) is
Operating System/1 (shortened to OS/1) is
a simple 16-bit operating system written in
assembly under a cross-compiled GNU Assembler
for the Intel i386 CPU.
assembly using NASM for the Intel i286 CPU.

To compile OS/1 just run : `make` in the root
of the directory.
Expand All @@ -13,5 +12,5 @@
Github repository.

List of software needed to build OS/1 :
* i386-elf GNU Binutils
* NASM
* QEMU (or any other emulator)
Binary file added bin/bootld.bin
Binary file not shown.
Binary file added bin/dune.bin
Binary file not shown.
Binary file added bin/os1.bin
Binary file not shown.
10 changes: 10 additions & 0 deletions boot/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

NASM := nasm -f bin

override BOOT := bootld.bin

.PHONY: all
all: $(BOOT)

$(BOOT):
$(NASM) boot16.nasm -o ../bin/$(BOOT)
31 changes: 31 additions & 0 deletions boot/boot16.nasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

org 0x7c00 ; Start @ 0x0000:0x7c00
cpu 286 ; Target 80286 CPU
bits 16 ; Generate 16-bit code
jmp _start ; Skip to _start

; Include bootloader lib.
%include "lib16.nasm"

_start: ; Main bootloader func.
mov [bootd],dl ; Boot dev. value

mov bp, 0x7c00
mov sp, bp

mov si, msg_s ; Print start message
call _putsb

mov si, msg_l ; Print loading message
call _putsb

call disk_read ; Read disk function

jmp KERNEL ; Jump to the kernel addr.

; Strings
msg_s: db 13,10,"Operating System/1 Version 4.0.0",13,10,0
msg_l: db "Starting OS/1...",13,10,0

times 510-($-$$) db 0 ; Bootsect. padding
dw 0xaa55 ; Boot sig.
41 changes: 41 additions & 0 deletions boot/lib16.nasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

_putsb: ; Print out a string
lodsb
or al, al
jz .done

mov ah, 0x0e
int 0x10

jmp _putsb

.done:
ret
disk_read: ; Read 0xff sectors from the disk
mov ah, 2
mov al, 32
mov bx, KERNEL
mov ch, 0x00
mov cl, 0x02
mov dh, 0x00
mov dl, [bootd]

int 0x13

jc .fail ; Jump to the fail if error c. present

ret

.fail:
mov si, msg_de ; Print out the error msg.
call _putsb

mov ax, 0x00
int 0x16 ; Wait for input
int 0x19 ; Reboot

; Varaibles
bootd: db 0
KERNEL equ 0x7e00
msg_de: db "Disk read error occurred",13,10,"Press any key to reboot",0
13 changes: 0 additions & 13 deletions bootld/Makefile

This file was deleted.

50 changes: 0 additions & 50 deletions bootld/boot16.S

This file was deleted.

61 changes: 0 additions & 61 deletions bootld/libb16.S

This file was deleted.

22 changes: 0 additions & 22 deletions bootld/link16.ld

This file was deleted.

Binary file added disk.img
Binary file not shown.
10 changes: 10 additions & 0 deletions dune/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

NASM := nasm -f bin

override DUNE := dune.bin

.PHONY: all
all: $(DUNE)

$(DUNE):
$(NASM) dune16.nasm -o ../bin/$(DUNE)
29 changes: 29 additions & 0 deletions dune/dune16.nasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

;*****************************************************************************;
; /dune/dune16.nasm ;
; ----------------------------------------------------------------------- ;
; Main (16-bit) source file for the DUNE kernel. ;
;*****************************************************************************;


org 0x7e00
bits 16
jmp _start

; File includes
%include "i286/stdio.inc"
%include "osh/main16.nasm"
%include "ed/ed.nasm"

_start:

mov ax, 0x0003
int 0x10

mov si, msg_2
call puts16

jmp _main_osh

; Strings
msg_2: db "DUNE kernel v1.00 (for i286) | Running in DOS mode",13,10,0
59 changes: 59 additions & 0 deletions dune/ed/ed.nasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

_main_ed:
mov si, start_msg
call puts16

.ed_l:
mov ax, 0x00
int 0x16

cmp al, 0x1b
je .done

cmp al, 0x08
je .backpsace

cmp al, 0x0d
je .return

mov ah, 0x0e
int 0x10
jmp .ed_l

.backpsace:
dec di
mov byte [di], 0
dec cl

mov ah, 0x0e
mov al, 0x08
int 0x10

mov al, ' '
int 0x10

mov al, 0x08
int 0x10

jmp .ed_l

.return:
mov al, 0x00
stosb

mov ah, 0x0e
mov al, 0x0d
int 0x10

mov al, 0x0a
int 0x10

jmp .ed_l
.done:
ret

cli
hlt

; Strings
start_msg: db " EDitor v001 | ESC to exit",13,10, 0
Loading

0 comments on commit c22917b

Please sign in to comment.