Permalink
Browse files

Bug fixes and new error codes

  • Loading branch information...
vialamo committed Feb 19, 2017
1 parent 6acf066 commit b102143c0479b4f5384873150c475d4655f7cdba
Showing with 747 additions and 285 deletions.
  1. +14 −7 Makefile
  2. +4 −4 README.md
  3. +16 −9 fstools/mkfs.c
  4. +447 −143 source/fs.c
  5. +2 −2 source/hw86.h
  6. +36 −2 source/hw86.s
  7. +118 −69 source/kernel.c
  8. +3 −0 source/kernel.h
  9. +47 −27 source/programs/edit.c
  10. +2 −1 source/syscall.h
  11. +41 −13 source/ulib/ulib.c
  12. +17 −8 source/ulib/ulib.h
View
@@ -1,20 +1,26 @@
# Makefile
# Directories
IMAGEDIR := images/
SOURCEDIR := source/
FSTOOLSDIR := fstools/
MKSRCVARS := IMGDIR=$(IMAGEDIR)
# User files and args for mkfs
USERFILES := $(SOURCEDIR)programs/edit.bin
MKFSARGS := $(SOURCEDIR)boot/boot.bin $(SOURCEDIR)kernel.n16 $(USERFILES)
# Make source and create images
all: $(FSTOOLSDIR)mkfs
$(MAKE) $@ -C $(SOURCEDIR) --no-print-directory $(MKSRCVARS)
$(MAKE) $@ -C $(SOURCEDIR) --no-print-directory
mkdir -p $(IMAGEDIR)
$(FSTOOLSDIR)mkfs $(IMAGEDIR)os-fd.img 2880 $(SOURCEDIR)kernel.n16 $(SOURCEDIR)programs/edit.bin
dd status=noxfer conv=notrunc if=$(SOURCEDIR)boot/boot.bin of=$(IMAGEDIR)os-fd.img status=none
$(FSTOOLSDIR)mkfs $(IMAGEDIR)os-hd.img 28800 $(SOURCEDIR)kernel.n16 $(SOURCEDIR)programs/edit.bin
dd status=noxfer conv=notrunc if=$(SOURCEDIR)boot/boot.bin of=$(IMAGEDIR)os-hd.img status=none
$(FSTOOLSDIR)mkfs $(IMAGEDIR)os-fd.img 2880 $(MKFSARGS)
$(FSTOOLSDIR)mkfs $(IMAGEDIR)os-hd.img 28800 $(MKFSARGS)
# mkfs generates disk images
$(FSTOOLSDIR)mkfs: $(FSTOOLSDIR)mkfs.c $(SOURCEDIR)fs.h
gcc -Werror -Wall -I$(SOURCEDIR) -o $(FSTOOLSDIR)mkfs $(FSTOOLSDIR)mkfs.c
# Generate tags
ctags:
ctags -R
@@ -29,10 +35,11 @@ QEMUOPTS = -drive file=$(IMAGEDIR)os-fd.img,if=floppy,media=disk,format=raw \
qemu: all
$(QEMU) $(QEMUOPTS)
# Clean
clean:
rm -f $(FSTOOLSDIR)mkfs
rm -f tags
rm -f $(IMAGEDIR)os-fd.img $(IMAGEDIR)os-hd.img
$(MAKE) $@ -C $(SOURCEDIR) --no-print-directory $(MKSRCVARS)
$(MAKE) $@ -C $(SOURCEDIR) --no-print-directory
.PHONY: all ctags qemu clean
View
@@ -17,20 +17,20 @@ System requirements:
The building process is expected to be executed in a Linux system. In Windows 10 it can be built using Windows Subsystem for Linux.
1. Install required software:
* make, gcc, bcc, nasm and ld86 to build the OS and apps
* dd to create disk images
* make, gcc, bcc, nasm and ld86 to build the OS and user programs
* optionally install qemu x86 emulator to test the images in a virtual machine
* optionally install exuberant-ctags to generate tags
* optionally use dd to write disk images on storage devices
2. Get full source code tree. In this tree there are several directories:
2. Get full source code tree. The tree contains the following directories:
* fstools: disk image generation tool
* images: output folder for generated disk images
* source: source code
* boot: code for the boot sector image
* ulib: library to develop user programs
* programs: user programs
3. Build: Customize `Makefile` and `source/Makefile` files. Run `make` from the root directory to build everything. Images will be generated in the "images" directory.
3. Build: Customize `Makefile` and `source/Makefile` files. Run `make` from the root directory to build everything. Images will be generated in the `images` directory.
##Testing
After building, run `make qemu` (linux) or `qemu.bat` (windows) from the root directory to test the OS in a virtual machine.
View
@@ -49,9 +49,9 @@ int main(int argc, char *argv[])
sizeof(struct SFS_ENTRY) % BLOCK_SIZE == 0);
// Check usage
if(argc < 3) {
if(argc < 5) {
fprintf(stderr,
"Usage: %s output_file fs_size_blocks kernel_file [other_files ...]\n",
"Usage: %s output_file fs_size_blocks boot_sect kernel_file [other_files ...]\n",
argv[0]);
exit(1);
@@ -69,10 +69,17 @@ int main(int argc, char *argv[])
exit(1);
}
// Write empty boot block, with boot signature
// Create empty boot block
memset(buf, 0, sizeof(buf));
buf[510] = 0xAA;
buf[511] = 0x55;
// Now add boot image to the block
if((fd = open(argv[3], 0)) < 0) {
perror(argv[3]);
exit(1);
}
read(fd, buf, 512);
close(fd);
wblock(0, buf);
// Write all image with 0s
@@ -99,18 +106,18 @@ int main(int argc, char *argv[])
b = sfs_sb.bootstart;
// Create root dir
strcpy(sfs_entry[e].name, ROOT_DIR_NAME);
strncpy(sfs_entry[e].name, ROOT_DIR_NAME, SFS_NAMESIZE-1);
sfs_entry[e].flags = T_DIR;
sfs_entry[e].time = 0;
sfs_entry[e].size = argc - 3;
sfs_entry[e].size = argc - 4;
sfs_entry[e].parent = 0;
sfs_entry[e].next = 0;
e++;
// Copy input files to image
// The first one is expected to be the kernel
for(f = 3; f < argc; f++) {
for(f = 4; f < argc; f++) {
// Open file
if((fd = open(argv[f], 0)) < 0) {
@@ -127,7 +134,7 @@ int main(int argc, char *argv[])
}
// Create first file entry
sfs_entry[0].ref[f - 3] = e;
sfs_entry[0].ref[f - 4] = e;
strncpy(sfs_entry[e].name, name, SFS_NAMESIZE-1);
sfs_entry[e].flags = T_FILE;
Oops, something went wrong.

0 comments on commit b102143

Please sign in to comment.