Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ endif
# the default of FLOPPY is used by 'build'.
#

ROOT_DEV = CURRENT
ROOT_DEV = OTHER

#
# If you want to preset the SVGA mode, uncomment the next line and
Expand All @@ -50,16 +50,20 @@ SVGA_MODE= -DSVGA_MODE=NORMAL_VGA
# standard CFLAGS
#

CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe
CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe \
-w -m32 -I$(PWD)/include/ -std=gnu89 \
-fno-stack-protector -fno-builtin -mmanual-endbr \
-fno-reorder-blocks-and-partition
#-Wno-attribute-alias

ifdef CONFIG_CPP
CFLAGS := $(CFLAGS) -x c++
endif

ifdef CONFIG_M486
CFLAGS := $(CFLAGS) -m486
#CFLAGS := $(CFLAGS) -m486
else
CFLAGS := $(CFLAGS) -m386
#CFLAGS := $(CFLAGS) -m386
endif

#
Expand All @@ -69,18 +73,18 @@ endif

#RAMDISK = -DRAMDISK=512

AS86 =i686-linux-gnu-as -0 -a
LD86 =i686-linux-gnu-ld -0
AS86 =as86 -0 -a
LD86 =ld86 -0

AS =i686-linux-gnu-as
LD =i686-linux-gnu-ld
AS =as --32
LD =ld -m elf_i386
LDFLAGS =#-qmagic
HOSTCC =gcc-4.8
CC =gcc-4.8 -D__KERNEL__
HOSTCC =gcc
CC =gcc -D__KERNEL__
MAKE =make
CPP =$(CC) -E
AR =i686-linux-gnu-ar
STRIP =i686-linux-gnu-strip
CPP =$(CC) -E -I$(PWD)/include/
AR =ar
STRIP =strip

ARCHIVES =kernel/kernel.o mm/mm.o fs/fs.o net/net.o ipc/ipc.o
FILESYSTEMS =fs/filesystems.a
Expand Down Expand Up @@ -181,7 +185,15 @@ zBoot/zSystem: zBoot/*.c zBoot/*.S tools/zSystem
$(MAKE) -C zBoot

zImage: $(CONFIGURE) boot/bootsect boot/setup zBoot/zSystem tools/build
tools/build boot/bootsect boot/setup zBoot/zSystem $(ROOT_DEV) > zImage
#tools/build boot/bootsect boot/setup zBoot/zSystem $(ROOT_DEV) > zImage
dd if=boot/bootsect skip=32 bs=1 of=bootsect.bin
dd if=boot/setup skip=32 bs=1 of=setup.bin
cat bootsect.bin setup.bin > zImage
cat zImage | dd of=zImage bs=2560 conv=sync
objcopy -O binary -j.text -j.data -j.rodata -j.bss zBoot/zSystem zSystem.bin
cat zSystem.bin >> zImage
cat zImage | dd of=zImage bs=1M conv=sync
ln -s zImage zImage.img
sync

zdisk: zImage
Expand Down Expand Up @@ -234,6 +246,11 @@ clean:
rm -f zBoot/zSystem zBoot/xtract zBoot/piggyback
rm -f .tmp* drivers/sound/configure
rm -f init/*.o tools/build boot/*.o tools/*.o
rm -f zBoot/a.out.gz
rm -f zSystem.bin
rm -f zImage.img
rm -f setup.bin
rm -f bootsect.bin

mrproper: clean
rm -f include/linux/autoconf.h tools/version.h
Expand Down
36 changes: 31 additions & 5 deletions boot/bootsect.S
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ SWAP_DEV = 0
! ld86 requires an entry symbol. This may as well be the usual one.
.globl _main
_main:


#if 0 /* hook for debugger, harmless unless BIOS is fussy (old HP) */
int 3
#endif
mov ax,#BOOTSEG
mov ds,ax
Expand All @@ -67,8 +68,8 @@ _main:
rep
movsw
jmpi go,INITSEG

go: mov ax,cs
go: ! now we shoud be in ip:0, cs:BOOTSEG
mov ax,cs
mov dx,#0x4000-12 ! 0x4000 is arbitrary value >= length of
! bootsect + length of setup + room for stack
! 12 is disk parm size
Expand Down Expand Up @@ -131,7 +132,7 @@ go: mov ax,cs
int 0x13

! load the setup-sectors directly after the bootblock.
! Note that 'es' is already set up.
! Note that 'es' is already set up

load_setup:
xor dx, dx ! drive 0, head 0
Expand Down Expand Up @@ -218,7 +219,6 @@ got_sectors:
! defined (!= 0), nothing is done and the given device is used.
! Otherwise, either /dev/PS0 (2,28) or /dev/at0 (2,8), depending
! on the number of sectors that the BIOS reports currently.

seg cs
mov ax,root_dev
or ax,ax
Expand All @@ -236,9 +236,35 @@ root_defined:
seg cs
mov root_dev,ax

#if 0
! after that (everyting loaded), we jump to
! the setup-routine loaded directly after
! the bootblock:
mov ax, #SETUPSEG
mov ds, ax

mov cx, #5
mov bx, #0

mem_dump:
seg ds
mov di, (bx)
add bx, #2
mov ax, di
push cx
#TODO: finish print memory
push ax ! dump number
mov bp, sp ! dump number
call print_hex ! print that number
pop ax ! fix stack address
call print_nl
pop cx
loop mem_dump

inf: jmp inf
; mov ax, #0x4141 ! CR
; int 0x10
#endif

jmpi 0,SETUPSEG

Expand Down
Loading