Skip to content

Commit 13b5d2a

Browse files
author
bajdcc
committed
Fix: Syntax error and qemu script
1 parent 1ec1ac7 commit 13b5d2a

File tree

7 files changed

+18
-20
lines changed

7 files changed

+18
-20
lines changed

Makefile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@ UOBJS := $(UPROGS:%=%.o)
3434

3535
# default task
3636
default: Makefile
37-
$(MAKE) bin/floppy.raw
3837
$(MAKE) bin/floppy.img
3938

4039
# create a 1.44MB floppy include kernel and bootsector
41-
bin/floppy.raw: boot/floppy.asm bin/bootsect.bin bin/kernel
40+
bin/floppy.img: boot/floppy.asm bin/bootsect.bin bin/kernel
4241
$(AS) -I ./bin/ -f bin -l lst/floppy.s $< -o $@
43-
44-
bin/floppy.img:
45-
$(IMG) convert -f raw -O qcow2 bin/floppy.raw bin/floppy.img
4642

4743
# bootsector
4844
bin/bootsect.bin: boot/bootsect.asm
@@ -82,24 +78,26 @@ init:
8278
# make a disk with minix v1 file system
8379
fs: $(UPROGS)
8480
$(DEL) bin/rootfs.img
85-
$(IMG) create -f raw bin/rootfs.raw 10M
86-
$(MKFS) bin/rootfs.raw -1 -n14
87-
sudo mount -o loop -t minix bin/rootfs.raw $(ROOTFS)
81+
$(IMG) create -f raw bin/rootfs.img 10M
82+
$(MKFS) bin/rootfs.img -1 -n14
83+
sudo mount -o loop -t minix bin/rootfs.img $(ROOTFS)
8884
mkdir $(ROOTFS)/bin
8985
mkdir $(ROOTFS)/share
9086
cp usr/logo.txt $(ROOTFS)/share
9187
for i in $(UPROGS); do cp $$i $(ROOTFS)/bin; done
9288
sleep 1
9389
sudo umount $(ROOTFS)
94-
$(IMG) convert -f raw -O qcow2 bin/rootfs.raw bin/rootfs.img
9590

9691
# check root file system
9792
fsck:
98-
$(FSCK) -fsl bin/rootfs.raw
93+
$(FSCK) -fsl bin/rootfs.img
9994

10095
# run with qemu
10196
run:
102-
$(QEMU) -S -s -fda bin/floppy.img -hda bin/rootfs.img -boot a &
97+
$(QEMU) -S -s \
98+
-drive file=bin/floppy.img,if=floppy,format=raw \
99+
-drive file=bin/rootfs.img,if=ide,format=raw,cyls=20,heads=16,secs=63 \
100+
-boot a -m 512 &
103101
sleep 1
104102
$(GDB) -x script/gdbinit
105103

include/isr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct int_frame {
1616
uint32_t gs; // 16 bits
1717
uint32_t fs; // 16 bits
1818
uint32_t es; // 16 bits
19-
uint32_t ds; // 16 bits
19+
uint32_t ds; // 16 bits
2020

2121
/* registers save by pusha */
2222
uint32_t edi;

script/gdbinit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ target remote localhost:1234
22
symbol-file bin/kernel.elf
33
b fault_handler
44
b panic
5-
b context_switch
5+
b exec
66
c

src/kernel/fault.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void fault_handler(struct int_frame *r) {
146146
print("error code: %d\n", r->err_code);
147147
panic(fault_msg[r->int_no]);
148148
} else {
149-
panic("Unkonwn Interrupt, System Halted!\n");
149+
panic("Unknown Interrupt, System Halted!\n");
150150
}
151151
}
152152

src/kernel/idt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
// std
77
#include <type.h>
8+
#include <print.h>
89
// x86
910
#include <pm.h>
1011
// lib

src/proc/exec.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ int exec(char *path, char **argv) {
3838
if (iread(ip, (char *)&eh, 0, sizeof(eh)) < (int)sizeof(eh)) {
3939
goto bad;
4040
}
41-
// print_elfhdr(&eh);
4241

4342
if (eh.magic != ELF_MAGIC) {
4443
goto bad;

src/user/cinit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#include <usys.h>
22
#include <uio.h>
33

4-
int main(){
4+
int main() {
55
char *argv[] = {"sh", 0};
66

7-
if (uio_init() < 0){
7+
if (uio_init() < 0) {
88
goto bad;
99
}
1010

1111
int pid = _fork();
12-
if (pid == 0){
13-
if (_exec("/bin/sh", argv) < 0){
12+
if (pid == 0) {
13+
if (_exec("/bin/sh", argv) < 0) {
1414
goto bad;
1515
}
16-
} else if (pid < 0){
16+
} else if (pid < 0) {
1717
goto bad;
1818
}
1919

0 commit comments

Comments
 (0)