Import backup from 2004-03-15

This commit is contained in:
Josh Holtrop 2004-03-15 22:00:00 -05:00
parent ab576bf18f
commit 7110307896
4 changed files with 160 additions and 163 deletions

233
Makefile
View File

@ -1,116 +1,117 @@
##################################################################### #####################################################################
# Author: Benjamen R. Meyer # # Author: Benjamen R. Meyer #
# Date: 2004-2-15 # # Date: 2004-2-15 #
# Purpose: To build Josh Holtrop's OS (HOS) using GNU make # # Purpose: To build Josh Holtrop's OS (HOS) using GNU make #
# Note: This makefile is for use on Linux & other Unix-like systems # # Note: This makefile is for use on Linux & other Unix-like systems #
##################################################################### #####################################################################
############## ##############
# Variables: # # Variables: #
############## ##############
# Information for creating a floppy image # Information for creating a floppy image
# Note: FLOPPY_FS and FLOPPY_FAT_SIZE are related fields. # Note: FLOPPY_FS and FLOPPY_FAT_SIZE are related fields.
# FLOPPY_FAT_SIZE should be either 12 or 16, # FLOPPY_FAT_SIZE should be either 12 or 16,
# depending on if FLOPPY_FS is FAT12 or FAT16, respectively. # depending on if FLOPPY_FS is FAT12 or FAT16, respectively.
MKDOSFS_PROG=/sbin/mkdosfs MKDOSFS_PROG=/sbin/mkdosfs
FLOPPY_IMAGE=floppy.img FLOPPY_IMAGE=floppy.img
FLOPPY_BLOCK_COUNT=1440 FLOPPY_BLOCK_COUNT=1440
FLOPPY_FS=FAT12 FLOPPY_FS=FAT12
FLOPPY_FAT_SIZE=12 FLOPPY_FAT_SIZE=12
FLOPPY_MOUNT=./floppy_image FLOPPY_MOUNT=./floppy_image
# Floppy images are good for programs like VMware and Bochs Pentium Emulator. ;-) # Floppy images are good for programs like VMware and Bochs Pentium Emulator. ;-)
# Program for copying # Program for copying
COPY_BIN=cp COPY_BIN=cp
########################################## ##########################################
# Build the IPL (Boot Loader) and Kernel # # Build the IPL (Boot Loader) and Kernel #
########################################## ##########################################
all: all:
# A word of warning to users :-> And a little helpful information ;-) # A word of warning to users :-> And a little helpful information ;-)
@echo "Installation must be done as root." @echo "Installation must be done as root."
@echo "Type 'make install' to install to a floppy in drive '/dev/fd0'" @echo "Type 'make install' to install to a floppy in drive '/dev/fd0'"
@echo "Type 'make install_img' to create a floppy image and install to it." @echo "Type 'make install_img' to create a floppy image and install to it."
cd boot; make cd boot; make
cd kernel; make cd kernel; make
################################################# #################################################
# Clean up the source directory of any binaries # # Clean up the source directory of any binaries #
################################################# #################################################
clean: clean:
cd boot; make clean cd boot; make clean
cd kernel; make clean cd kernel; make clean
########################################### ###########################################
# The following is for the floppy drive # # The following is for the floppy drive #
# Note: This must be done on *nix as root # # Note: This must be done on *nix as root #
########################################### ###########################################
########################## ##########################
# Make install to floppy # # Make install to floppy #
########################## ##########################
install: Install_IPL File_Copy install: Install_IPL File_Copy
############################################ ############################################
# Write the Stage 1 IPL to the boot sector # # Write the Stage 1 IPL to the boot sector #
############################################ ############################################
Install_IPL: Install_IPL:
$(MKDOSFS_PROG) /dev/fd0 $(MKDOSFS_PROG) /dev/fd0
dd if=boot/stage1.bin of=/dev/fd0 dd if=boot/stage1.bin of=/dev/fd0
################################# #################################
# Copy the files onto the drive # # Copy the files onto the drive #
################################# #################################
File_Copy: File_Copy:
mkdir floppy_mount - mkdir floppy_mount
@echo "Mounting floppy to ./floppy_mount..." @echo "Mounting floppy to ./floppy_mount..."
mount /dev/fd0 ./floppy_mount mount /dev/fd0 ./floppy_mount
@echo "Copying stage 2 bootloader to the floppy..." @echo "Copying stage 2 bootloader to the floppy..."
$(COPY_BIN) boot/stage2.bin ./floppy_mount $(COPY_BIN) boot/stage2.bin ./floppy_mount
@echo "Copying kernel to the floppy..." @echo "Copying kernel to the floppy..."
$(COPY_BIN) kernel/kernel.bin ./floppy_mount $(COPY_BIN) kernel/kernel.bin ./floppy_mount
@echo "Unmounting floppy..." @echo "Unmounting floppy..."
umount ./floppy_mount umount ./floppy_mount
rm -rf floppy_mount - rm -rf floppy_mount
############################################ ############################################
# The following is for the floppy image. # # The following is for the floppy image. #
# Note: This must be done on *nix as root. # # Note: This must be done on *nix as root. #
############################################ ############################################
###################################### ######################################
# Create and Format the floppy image # # Create and Format the floppy image #
###################################### ######################################
install_img: install_img:
$(MKDOSFS_PROG) -C -F $(FLOPPY_FAT_SIZE) -r 112 $(FLOPPY_IMAGE) $(FLOPPY_BLOCK_COUNT) $(MKDOSFS_PROG) -C -F $(FLOPPY_FAT_SIZE) -r 112 $(FLOPPY_IMAGE) $(FLOPPY_BLOCK_COUNT)
############################################ ############################################
# Write the Stage 1 IPL to the boot sector # # Write the Stage 1 IPL to the boot sector #
############################################ ############################################
@echo "Writing boot sector to image..." @echo "Writing boot sector to image..."
dd if=stage1.bin of=$(FLOPPY_IMAGE) seek=0 dd if=stage1.bin of=$(FLOPPY_IMAGE) seek=0
################################# #################################
# Copy the files onto the image # # Copy the files onto the image #
################################# #################################
@echo "Mounting floppy image..." - mkdir $(FLOPPY_MOUNT)
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop @echo "Mounting floppy image..."
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
@echo "Copying stage 2 bootloader to the floppy image..."
$(COPY_BIN) stage2.bin $(FLOPPY_MOUNT) @echo "Copying stage 2 bootloader to the floppy image..."
@echo "Copying kernel to the floppy image..." $(COPY_BIN) stage2.bin $(FLOPPY_MOUNT)
$(COPY_BIN) kernel.bin $(FLOPPY_MOUNT) @echo "Copying kernel to the floppy image..."
$(COPY_BIN) kernel.bin $(FLOPPY_MOUNT)
@echo "Unmounting floppy image..."
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop @echo "Unmounting floppy image..."
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop

View File

@ -1,33 +1,42 @@
// vfs.c // vfs.c
// Author: Josh Holtrop // Author: Josh Holtrop
// Date: 03/11/04 // Date: 03/11/04
#include "vfs.h" #include "vfs.h"
#include "hos_defines.h" #include "hos_defines.h"
Volume *firstVolume = 0; Volume *firstVolume = 0;
Volume *rootVolume = 0;
void vfs_init()
{ void vfs_init()
dword initrdLoaded = *(byte *)BOOT_HASRD; {
if(*(byte *)BOOT_HASRD) //bootloader loaded an initial ram disk
} {
Volume *initrd = vfs_newVolume();
RamDisk *rd = rd_newDisk(0xC0200000, 1440*1024);
Volume *vfs_newVolume() initrd->diskDevice = rd;
{ initrd->deviceType = VFS_RD;
Volume *vol = malloc(sizeof(Volume)); strcpy(initrd->label, "rd0");
vfs_getLastVolume()->link = vol; initrd->link = 0;
return vol; rootVolume = initrd;
} }
}
Volume *vfs_getLastVolume()
{ Volume *vfs_newVolume()
Volume *vol = firstVolume; {
while (vol) Volume *vol = malloc(sizeof(Volume));
vol = vol->link; vfs_getLastVolume()->link = vol;
return vol; return vol;
} }
Volume *vfs_getLastVolume()
{
Volume *vol = firstVolume;
while (vol)
vol = vol->link;
return vol;
}

View File

@ -139,7 +139,7 @@ void putHex(dword number)
void kio_putBCD(dword bcd) void kio_putBCD(dword bcd)
{ {
putc(((bcd & 0xF) >> 4) + '0'); putc(((bcd & 0xF0) >> 4) + '0');
putc((bcd & 0xF) + '0'); putc((bcd & 0xF) + '0');
} }

View File

@ -1,13 +0,0 @@
Exception: STATUS_ACCESS_VIOLATION at eip=00462A1A
eax=00000000 ebx=00001000 ecx=0A04865C edx=00000200 esi=0A04724C edi=FFFFFE00
ebp=0022EB88 esp=0022EB20 program=C:\cygwin\bin\ld.exe
cs=001B ds=0023 es=0023 fs=0038 gs=0000 ss=0023
Stack trace:
Frame Function Args
0022EB88 00462A1A (0A046CD8, 0022EC70, 0A04EF10, 610D3F69)
0022EE68 00448567 (0A046CD8, 30303030, 0022EE00, 0A04E758)
0022EEF8 0043FCA0 (0A046CD8, 0041BBDE, 77E88AC8, FFFFFFFF)
0022EF40 0041C322 (0000001B, 6167241C, 0A0400A8, 0022EF98)
0022EF80 61005DE0 (0022EF98, 00000000, 002304CC, 536CD652)
0022FF90 61005EE5 (00000000, 00000000, 00000000, 00000000)
End of stack trace