16.04上执行第五章第i个程序成功了


16.04上执行第五章第i个程序成功了

配置文件:
[email protected]:/home/OS_Self/chapter5/i# cat a.txt 
###############################################################
# bochsrc.bxrc file for Tinix.
###############################################################

# how much memory the emulated machine will have
megs: 32

display_library: sdl

# filename of ROM images
romimage: file=$BXSHARE/BIOS-bochs-latest
vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest

# what disk images will be used 
floppya: 1_44=a.img, status=inserted

# choose the boot disk.
boot: a

# where do we send log messages?
log: bochsout.txt

# disable the mouse, since Tinix is text only
mouse: enabled=0

# enable key mapping, using US layout as default.
keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/sdl-pc-us.map


Makefile(由于我的系统是64位的,编译32位的时候需要加对应参数):

[email protected]:/home/OS_Self/chapter5/i# cat Makefile
#########################
# Makefile for Orange'S #
#########################


# Entry point of Orange'S
# It must have the same value with 'KernelEntryPointPhyAddr' in load.inc!
ENTRYPOINT = 0x30400


# Offset of entry point in kernel file
# It depends on ENTRYPOINT
ENTRYOFFSET =   0x400


# Programs, flags, etc.
ASM = nasm
DASM = ndisasm
CC = gcc -m32
LD = ld
ASMBFLAGS = -I boot/include/
ASMKFLAGS = -I include/ -f elf
CFLAGS = -I include/ -c -fno-builtin -fno-stack-protector
LDFLAGS = -s -m elf_i386 -Ttext $(ENTRYPOINT)
DASMFLAGS = -u -o $(ENTRYPOINT) -e $(ENTRYOFFSET)


# This Program
ORANGESBOOT = boot/boot.bin boot/loader.bin
ORANGESKERNEL = kernel.bin
OBJS = kernel/kernel.o kernel/start.o kernel/i8259.o kernel/global.o kernel/protect.o lib/klib.o lib/kliba.o lib/string.o
DASMOUTPUT = kernel.bin.asm


# All Phony Targets
.PHONY : everything final image clean realclean disasm all buildimg


# Default starting position
everything : $(ORANGESBOOT) $(ORANGESKERNEL)


all : realclean everything


final : all clean


image : final buildimg


clean :
rm -f $(OBJS)


realclean :
rm -f $(OBJS) $(ORANGESBOOT) $(ORANGESKERNEL)


disasm :
$(DASM) $(DASMFLAGS) $(ORANGESKERNEL) > $(DASMOUTPUT)


# We assume that "a.img" exists in current folder
buildimg :
dd if=boot/boot.bin of=a.img bs=512 count=1 conv=notrunc
sudo mount -o loop a.img /mnt/floppy/
sudo cp -fv boot/loader.bin /mnt/floppy/
sudo cp -fv kernel.bin /mnt/floppy
sudo umount /mnt/floppy


boot/boot.bin : boot/boot.asm boot/include/load.inc boot/include/fat12hdr.inc
$(ASM) $(ASMBFLAGS) -o [email protected] $<


boot/loader.bin : boot/loader.asm boot/include/load.inc \
boot/include/fat12hdr.inc boot/include/pm.inc
$(ASM) $(ASMBFLAGS) -o [email protected] $<


$(ORANGESKERNEL) : $(OBJS)
$(LD) $(LDFLAGS) -o $(ORANGESKERNEL) $(OBJS)


kernel/kernel.o : kernel/kernel.asm
$(ASM) $(ASMKFLAGS) -o [email protected] $<


kernel/start.o: kernel/start.c include/type.h include/const.h include/protect.h \
include/proto.h include/string.h
$(CC) $(CFLAGS) -o [email protected] $<


kernel/i8259.o : kernel/i8259.c include/type.h include/const.h include/protect.h \
include/proto.h
$(CC) $(CFLAGS) -o [email protected] $<


kernel/global.o : kernel/global.c
$(CC) $(CFLAGS) -o [email protected] $<


kernel/protect.o : kernel/protect.c
$(CC) $(CFLAGS) -o [email protected] $<


lib/klib.o : lib/klib.c
$(CC) $(CFLAGS) -o [email protected] $<


lib/kliba.o : lib/kliba.asm
$(ASM) $(ASMKFLAGS) -o [email protected] $<


lib/string.o : lib/string.asm

$(ASM) $(ASMKFLAGS) -o [email protected] $<


编译命令:

make clean

make buildimg