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

mkdir /mnt/floppy

sudo apt-get install vgabios bochs bochs-x bximage

bochs -f b.txt(如果不行,需要reboot下电脑)

 

 

配置文件:
root@ubuntu:/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位的时候需要加对应参数):

root@ubuntu:/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 $@ $<


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


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


kernel/kernel.o : kernel/kernel.asm
$(ASM) $(ASMKFLAGS) -o $@ $<


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


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


kernel/global.o : kernel/global.c
$(CC) $(CFLAGS) -o $@ $<


kernel/protect.o : kernel/protect.c
$(CC) $(CFLAGS) -o $@ $<


lib/klib.o : lib/klib.c
$(CC) $(CFLAGS) -o $@ $<


lib/kliba.o : lib/kliba.asm
$(ASM) $(ASMKFLAGS) -o $@ $<


lib/string.o : lib/string.asm

$(ASM) $(ASMKFLAGS) -o $@ $<

 

编译命令:

make clean

make buildimg 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值