first commit

This commit is contained in:
d0p1 🏳️‍⚧️ 2020-05-06 12:40:10 +02:00
commit 3d4615d276
6 changed files with 138 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
*.o
*.img
*.bin
*~

29
LICENSE Normal file
View file

@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2020, d0p1
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

20
Makefile Normal file
View file

@ -0,0 +1,20 @@
all: stupid.img
stupid.img: floppy.bin kern.bin
cat $^ /dev/zero | dd of=$@ bs=512 count=2880
floppy.bin: boot/floppy.s
nasm -fbin -o $@ $^
kern.bin: kern/kernel.s
nasm -fbin -o $@ $^
clean:
rm floppy.bin kern.bin
fclean:
rm stupid.img
re: fclean all
.PHONY: all clean fclean re

4
README.md Normal file
View file

@ -0,0 +1,4 @@
# StupidOS
16bit real mode Operating System in assembly

81
boot/floppy.s Normal file
View file

@ -0,0 +1,81 @@
[ORG 0x7c00]
[BITS 16]
jmp short entry
nop
;; -----------------------------------------------------------
;; OEM & Bios Parameter Block
;; -----------------------------------------------------------
db "StupidOS"
dw 512 ; bytes per sector
db 1 ; sector per cluster
dw 1 ; reserved sector
db 2 ; number of FATs
dw 224 ; root entries
dw 2400 ; total sector
db 0xF9 ; media descriptor type
dw 7 ; sectors per FAT
dw 15 ; sectors per track
dw 2 ; heads per cylinder
dd 0 ; hidden sectors
dd 0 ; total sector big
db 0 ; drive number
db 0 ; unused
db 0x29 ; drive signature (0x29 = floppy)
dd 0x00000000 ; serial number (ignore)
db 'STUPID DISK' ; volume label
db 'FAT12 ' ; filesystem type
;; -----------------------------------------------------------
;; Print string using bios interrupt
;; -----------------------------------------------------------
boot_print:
pusha
.loop:
lodsb
cmp al, 0
jz .end
mov ah, 0x0E ; bios print
mov bx, 0x07
int 0x10
jmp .loop
.end:
popa
ret
;; -----------------------------------------------------------
;; Variables
;; -----------------------------------------------------------
copyright db "Copyright (c) d0p1", 13, 10, 0
err_disk_reset db "Error reseting disk..retry", 13, 10, 0
;; -----------------------------------------------------------
;; entry
;; -----------------------------------------------------------
entry:
xor ax, ax
mov ds, ax
mov si, copyright
call boot_print
reset_disk:
xor ah, ah
xor dl, dl
int 0x13
jnc .reset_disk_end
mov si, err_disk_reset
call boot_print
jmp reset_disk
.reset_disk_end:
hang:
jmp hang
cli
hlt
times 510-($-$$) db 0
db 0x55
db 0xAA

0
kern/kernel.s Normal file
View file