1 Star 0 Fork 1

lindy/xbook3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Makefile 2.98 KB
一键复制 编辑 原始数据 按行查看 历史
小骨头 提交于 2020-09-17 20:02 . support thread
# MIT License
# Copyright (c) 2020 Jason Hu
all:
# tools
MAKE = make
TRUNC = truncate
RM = rm
DD = dd
MKDIR = mkdir
# virtual machine
QEMU = qemu-system-i386
# images and rom
IMAGE_DIR = develop/image
FLOPPYA_IMG = $(IMAGE_DIR)/a.img
HDA_IMG = $(IMAGE_DIR)/c.img
HDB_IMG = $(IMAGE_DIR)/d.img
# image size
FLOPPYA_SZ = 1474560
HDA_SZ = 33554432
#kernel disk
LOADER_OFF = 2
LOADER_CNTS = 8
SETUP_OFF = 10
SETUP_CNTS = 90
KERNEL_OFF = 100
KERNEL_CNTS = 1024 # assume 512kb
# arch dir
BOOT_DIR := boot
KERNEL_DIR := kernel
ARCH_NAME := i386
# kernel boot binary
BOOT_BIN = $(BOOT_DIR)/$(ARCH_NAME)/boot.bin
LOADER_BIN = $(BOOT_DIR)/$(ARCH_NAME)/loader.bin
SETUP_BIN = $(BOOT_DIR)/$(ARCH_NAME)/setup.bin
# kernel file
KERNEL_ELF = $(KERNEL_DIR)/kernel.elf
# 参数
.PHONY: all kernel build debuild qemu qemudbg
# 默认所有动作,编译内核后,把引导、内核写入磁盘
all : kernel
$(DD) if=$(BOOT_BIN) of=$(FLOPPYA_IMG) bs=512 count=1 conv=notrunc
$(DD) if=$(LOADER_BIN) of=$(FLOPPYA_IMG) bs=512 seek=$(LOADER_OFF) count=$(LOADER_CNTS) conv=notrunc
$(DD) if=$(SETUP_BIN) of=$(FLOPPYA_IMG) bs=512 seek=$(SETUP_OFF) count=$(SETUP_CNTS) conv=notrunc
$(DD) if=$(KERNEL_ELF) of=$(FLOPPYA_IMG) bs=512 seek=$(KERNEL_OFF) count=$(KERNEL_CNTS) conv=notrunc
# run启动虚拟机
run: qemu
# 先写rom,在编译内核
kernel:
@$(MAKE) -s -C $(BOOT_DIR)
@$(MAKE) -s -C $(KERNEL_DIR)
clean:
@$(MAKE) -s -C $(BOOT_DIR) clean
@$(MAKE) -s -C $(KERNEL_DIR) clean
# 构建环境。镜像>工具>环境>rom
build:
-$(MKDIR) $(IMAGE_DIR)
$(TRUNC) -s $(FLOPPYA_SZ) $(FLOPPYA_IMG)
$(TRUNC) -s $(HDA_SZ) $(HDA_IMG)
# 清理环境。
debuild:
$(MAKE) -s -C $(KERNEL_DIR) clean
-$(RM) -r $(IMAGE_DIR)
#-hda $(HDA_IMG) -hdb $(HDB_IMG)
# 网卡配置:
# -net nic,vlan=0,model=rtl8139,macaddr=12:34:56:78:9a:be
# 网络模式:
# 1.User mode network(Slirp) :User网络
# -net user
# 2.Tap/tun network : Tap网络
# -net tap
# -net tap,vlan=0,ifname=tap0
# example: -net nic,model=rtl8139 -net tap,ifname=tap0,script=no,downscript=no
# 音频配置:
# a.使用蜂鸣器:-soundhw pcspk
# b.使用声霸卡:-soundhw sb16
# 控制台串口调试: -serial stdio
# 磁盘配置:
# 1. IDE DISK:-hda $(HDA_IMG) -hdb $(HDB_IMG) \
# 2. AHCI DISK: -drive id=disk0,file=$(HDA_IMG),if=none \
-drive id=disk1,file=$(HDB_IMG),if=none \
-device ahci,id=ahci \
-device ide-drive,drive=disk0,bus=ahci.0 \
-device ide-drive,drive=disk1,bus=ahci.1 \
QEMU_ARGUMENT = -m 256M \
-name "Xbook3 Development Platform for i386" \
-fda $(FLOPPYA_IMG) \
-drive id=disk0,file=$(HDA_IMG),if=none \
-device ahci,id=ahci \
-device ide-drive,drive=disk0,bus=ahci.0 \
-boot a \
-serial stdio \
# -fda $(FLOPPYA_IMG) -hda $(HDA_IMG) -hdb $(HDB_IMG) -boot a \
# -net nic,model=rtl8139 -net tap,ifname=tap0,script=no,downscript=no
# qemu启动
qemu: all
$(QEMU) $(QEMU_ARGUMENT)
# 调试配置:-S -gdb tcp::10001,ipv4
qemudbg: all
$(QEMU) -S -gdb tcp::10001,ipv4 $(QEMU_ARGUMENT)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/lindyld1314/xbook3.git
git@gitee.com:lindyld1314/xbook3.git
lindyld1314
xbook3
xbook3
master

搜索帮助