Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f5e3507ba | ||
|
|
a9a6f6f4d4 | ||
|
|
2d009273a1 | ||
|
|
2b936758ff | ||
|
|
509009d134 |
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
/hos.flp
|
||||||
|
/hos_initrd
|
||||||
|
/hos_initrd.gz
|
||||||
|
*.lst
|
||||||
|
*.map
|
||||||
|
*.bin
|
||||||
@@ -19,16 +19,16 @@ MAKEFLAGS += --no-print-directory
|
|||||||
.PHONY: all clean initrd apps grub_image install install_img depend copy_image bochs bochsq
|
.PHONY: all clean initrd apps grub_image install install_img depend copy_image bochs bochsq
|
||||||
|
|
||||||
all:
|
all:
|
||||||
make -C kernel
|
${MAKE} -C kernel
|
||||||
make -C rmmod
|
${MAKE} -C rmmod
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-make -C kernel clean
|
-${MAKE} -C kernel clean
|
||||||
-make -C rmmod clean
|
-${MAKE} -C rmmod clean
|
||||||
-rm -f *~ *.out hos.flp \#* hos_initrd hos_initrd.gz
|
-rm -f *~ *.out hos.flp \#* hos_initrd hos_initrd.gz
|
||||||
|
|
||||||
apps:
|
apps:
|
||||||
make -C apps
|
${MAKE} -C apps
|
||||||
|
|
||||||
grub_image:
|
grub_image:
|
||||||
dd if=/dev/zero of=$(GRUB_IMAGE) bs=1024 seek=1440 count=0
|
dd if=/dev/zero of=$(GRUB_IMAGE) bs=1024 seek=1440 count=0
|
||||||
@@ -75,7 +75,7 @@ initrd:
|
|||||||
gzip -c $(INITRD) > $(INITRD).gz
|
gzip -c $(INITRD) > $(INITRD).gz
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
make -C kernel depend
|
${MAKE} -C kernel depend
|
||||||
|
|
||||||
bochs:
|
bochs:
|
||||||
bochs
|
bochs
|
||||||
|
|||||||
+7
-6
@@ -5,18 +5,19 @@
|
|||||||
|
|
||||||
# Assembler Information:
|
# Assembler Information:
|
||||||
NASM=nasm
|
NASM=nasm
|
||||||
NASM_FLAGS=-f aout
|
NASM_FLAGS=-f elf32
|
||||||
|
|
||||||
# C/C++ Information:
|
# C/C++ Information:
|
||||||
CPPFLAGS=-fleading-underscore -fno-builtin -nostdlib -nostartfiles -nodefaultlibs -I. -Wall
|
CPPFLAGS=-ffreestanding -fno-builtin -nostdlib -nostartfiles -nodefaultlibs -I. -Wall -m32 -fno-pic
|
||||||
# -S -masm=intel
|
# -S -masm=intel
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CXX=g++
|
CXX=g++
|
||||||
CXXFLAGS=-fno-rtti -fno-exceptions -D_HOS_CPP_
|
CXXFLAGS=-fno-rtti -fno-exceptions -D_HOS_CPP_ -std=gnu++98
|
||||||
|
|
||||||
# Linker Information:
|
# Linker Information:
|
||||||
LD=ld
|
LD=gcc
|
||||||
LDFLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld
|
LDFLAGS=-ffreestanding -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -Wl,--no-demangle -T link.ld -m32
|
||||||
|
LIBS=-static-libgcc
|
||||||
|
|
||||||
# Files
|
# Files
|
||||||
OBJS=boot.o lang/lang_a.o \
|
OBJS=boot.o lang/lang_a.o \
|
||||||
@@ -43,7 +44,7 @@ CXXSRC=lang/string.cpp lang/new.cpp char/misc_char.cpp char/vconsole.cpp \
|
|||||||
.PHONY: all depend clean html
|
.PHONY: all depend clean html
|
||||||
|
|
||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
$(LD) $(LDFLAGS) -Map kernel.map $(OBJS) -o kernel.bin
|
$(LD) $(LDFLAGS) -Wl,-Map -Wl,kernel.map $(OBJS) -o kernel.bin $(LIBS)
|
||||||
@echo ' Kernel built: ' `ls -sk kernel.bin | cut -d' ' -f1`kb
|
@echo ' Kernel built: ' `ls -sk kernel.bin | cut -d' ' -f1`kb
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
|
|||||||
+14
-14
@@ -25,23 +25,23 @@
|
|||||||
%define KERNEL_P PHYS_START+0x8000 ;1mb+32kb - the kernel's physical address
|
%define KERNEL_P PHYS_START+0x8000 ;1mb+32kb - the kernel's physical address
|
||||||
%define KERNEL_V KERNEL_P+VIRT_OFFSET ;3gb+1mb+32kb, the virtual address of the kernel
|
%define KERNEL_V KERNEL_P+VIRT_OFFSET ;3gb+1mb+32kb, the virtual address of the kernel
|
||||||
|
|
||||||
extern _k_init, _isr, _k_mbsave, _end, _rm_params, _initrd, _tss0
|
extern k_init, isr, k_mbsave, end, rm_params, initrd, tss0
|
||||||
|
|
||||||
[bits 32]
|
[bits 32]
|
||||||
|
|
||||||
[global _start]
|
[global start]
|
||||||
_start:
|
start:
|
||||||
|
|
||||||
multiboot_header:
|
multiboot_header:
|
||||||
dd MULTIBOOT_MAGIC ;magic
|
dd MULTIBOOT_MAGIC ;magic
|
||||||
dd MULTIBOOT_FLAGS ;flags
|
dd MULTIBOOT_FLAGS ;flags
|
||||||
dd -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS) ;checksum
|
dd -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS) ;checksum
|
||||||
|
|
||||||
dd multiboot_header-VIRT_OFFSET ;header_addr
|
dd 0x100000000+multiboot_header-VIRT_OFFSET ;header_addr
|
||||||
dd _start-VIRT_OFFSET ;load_addr
|
dd 0x100000000+start-VIRT_OFFSET ;load_addr
|
||||||
dd 0 ;load_end_addr
|
dd 0 ;load_end_addr
|
||||||
dd _end-VIRT_OFFSET ;bss_end_addr
|
dd 0x100000000+end-VIRT_OFFSET ;bss_end_addr
|
||||||
dd multiboot_entry-VIRT_OFFSET ;entry_addr
|
dd 0x100000000+multiboot_entry-VIRT_OFFSET ;entry_addr
|
||||||
|
|
||||||
; dd 1 ;mode_type
|
; dd 1 ;mode_type
|
||||||
; dd 80 ;width
|
; dd 80 ;width
|
||||||
@@ -53,7 +53,7 @@ multiboot_entry:
|
|||||||
;This is where the kernel begins execution from the bootloader.
|
;This is where the kernel begins execution from the bootloader.
|
||||||
;At this point, a temporary gdt is set up to "map" 0xC000_0000 to 0x0.
|
;At this point, a temporary gdt is set up to "map" 0xC000_0000 to 0x0.
|
||||||
cli ;should already be off...
|
cli ;should already be off...
|
||||||
lgdt [gdtrbs32-VIRT_OFFSET]
|
lgdt [0x100000000+gdtrbs32-VIRT_OFFSET]
|
||||||
jmp KERNEL_CODE_BS32:segmented_start
|
jmp KERNEL_CODE_BS32:segmented_start
|
||||||
segmented_start:
|
segmented_start:
|
||||||
mov cx, KERNEL_DATA_BS32
|
mov cx, KERNEL_DATA_BS32
|
||||||
@@ -68,7 +68,7 @@ segmented_start:
|
|||||||
add ebx, VIRT_OFFSET
|
add ebx, VIRT_OFFSET
|
||||||
push eax
|
push eax
|
||||||
push ebx ;pointer to multiboot info structure
|
push ebx ;pointer to multiboot info structure
|
||||||
call _k_mbsave ;save multiboot info structures
|
call k_mbsave ;save multiboot info structures
|
||||||
add esp, 8
|
add esp, 8
|
||||||
|
|
||||||
cmp eax, 0 ; eax = pointer to mb_module_t struct for rmmod
|
cmp eax, 0 ; eax = pointer to mb_module_t struct for rmmod
|
||||||
@@ -86,7 +86,7 @@ segmented_start:
|
|||||||
rep movsd ; copy rmmod to first 1mb
|
rep movsd ; copy rmmod to first 1mb
|
||||||
|
|
||||||
mov ebx, pm_return ; return address
|
mov ebx, pm_return ; return address
|
||||||
mov ecx, _rm_params ; put real mode params here (video mode etc...)
|
mov ecx, rm_params ; put real mode params here (video mode etc...)
|
||||||
sub ecx, VIRT_OFFSET
|
sub ecx, VIRT_OFFSET
|
||||||
|
|
||||||
jmp 0xC0005010 ; jump to rmmod
|
jmp 0xC0005010 ; jump to rmmod
|
||||||
@@ -161,8 +161,8 @@ newgdtcontinue:
|
|||||||
lidt [idtr] ;load idt
|
lidt [idtr] ;load idt
|
||||||
mov [PDBR_V], dword 0 ;unmap 0x0, we are running completely paged at 0xC000_0000
|
mov [PDBR_V], dword 0 ;unmap 0x0, we are running completely paged at 0xC000_0000
|
||||||
|
|
||||||
mov edi, GDT_V + TSS0_SEG + 2 ; copy _tss0 base address
|
mov edi, GDT_V + TSS0_SEG + 2 ; copy tss0 base address
|
||||||
mov eax, _tss0 ; into the GDT descrtiptor
|
mov eax, tss0 ; into the GDT descrtiptor
|
||||||
stosw ; for TSS0
|
stosw ; for TSS0
|
||||||
shr eax, 16
|
shr eax, 16
|
||||||
stosb
|
stosb
|
||||||
@@ -170,7 +170,7 @@ newgdtcontinue:
|
|||||||
shr eax, 8
|
shr eax, 8
|
||||||
stosb
|
stosb
|
||||||
|
|
||||||
call _k_init ;C kernel initialization
|
call k_init ;C kernel initialization
|
||||||
|
|
||||||
mov ax, TSS0_SEG
|
mov ax, TSS0_SEG
|
||||||
ltr ax
|
ltr ax
|
||||||
@@ -187,7 +187,7 @@ idle_loop: ; system idle loop
|
|||||||
;-------------------------------------------------------
|
;-------------------------------------------------------
|
||||||
gdtrbs32:
|
gdtrbs32:
|
||||||
dw gdt_endbs32-gdtbs32-1
|
dw gdt_endbs32-gdtbs32-1
|
||||||
dd gdtbs32-VIRT_OFFSET
|
dd 0x100000000+gdtbs32-VIRT_OFFSET
|
||||||
gdtbs32: ; 0 = null descriptor
|
gdtbs32: ; 0 = null descriptor
|
||||||
dd 0
|
dd 0
|
||||||
dd 0
|
dd 0
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Ext2OpenFile::Ext2OpenFile(Ext2fs *fs, u32_t inum, int mode)
|
|||||||
myBlockCacheStatus = 0; /* 0: invalid; 1: valid; 2: dirty */
|
myBlockCacheStatus = 0; /* 0: invalid; 1: valid; 2: dirty */
|
||||||
fs->readInode(inum, &myInode);
|
fs->readInode(inum, &myInode);
|
||||||
myCache = new Ext2BlockCache(fs, inum, &myInode);
|
myCache = new Ext2BlockCache(fs, inum, &myInode);
|
||||||
lock(&Ext2OpenFileListLock);
|
lockit(&Ext2OpenFileListLock);
|
||||||
if ((mode & VFS_MODE_RW_MASK) == VFS_MODE_WRITE)
|
if ((mode & VFS_MODE_RW_MASK) == VFS_MODE_WRITE)
|
||||||
{
|
{
|
||||||
if ((mode & VFS_MODE_WRITE_MASK) == VFS_MODE_TRUNCATE)
|
if ((mode & VFS_MODE_WRITE_MASK) == VFS_MODE_TRUNCATE)
|
||||||
@@ -62,7 +62,7 @@ Ext2OpenFile::Ext2OpenFile(Ext2fs *fs, u32_t inum, int mode)
|
|||||||
Ext2OpenFile::~Ext2OpenFile()
|
Ext2OpenFile::~Ext2OpenFile()
|
||||||
{
|
{
|
||||||
/* remove ourselves from the open file list */
|
/* remove ourselves from the open file list */
|
||||||
lock(&Ext2OpenFileListLock);
|
lockit(&Ext2OpenFileListLock);
|
||||||
u32_t size = Ext2OpenFileList->size();
|
u32_t size = Ext2OpenFileList->size();
|
||||||
for (u32_t i = 0; i < size; i++)
|
for (u32_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,9 +9,15 @@
|
|||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "sys/io.h"
|
#include "sys/io.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
extern u32_t _code;
|
extern u32_t _code;
|
||||||
extern u32_t _bss;
|
extern u32_t _bss;
|
||||||
extern u32_t _end;
|
extern u32_t _end;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//Enables (SeTs) Interrupt Flag on the processor
|
//Enables (SeTs) Interrupt Flag on the processor
|
||||||
static inline void enable_ints()
|
static inline void enable_ints()
|
||||||
|
|||||||
@@ -44,9 +44,15 @@ typedef unsigned char u8_t;
|
|||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
typedef int lock_t;
|
typedef int lock_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
extern u32_t _end;
|
extern u32_t _end;
|
||||||
extern u32_t _bss;
|
extern u32_t _bss;
|
||||||
extern u32_t start;
|
extern u32_t start;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+1
-1
@@ -97,7 +97,7 @@ isr_main_nodup:
|
|||||||
|
|
||||||
push esp
|
push esp
|
||||||
push eax ;interrupt number
|
push eax ;interrupt number
|
||||||
call _isr
|
call isr
|
||||||
add esp, 8
|
add esp, 8
|
||||||
|
|
||||||
pop gs
|
pop gs
|
||||||
|
|||||||
+38
-38
@@ -13,8 +13,8 @@
|
|||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
;implements a lock
|
;implements a lock
|
||||||
[global _lock]
|
[global lockit]
|
||||||
_lock:
|
lockit:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push eax
|
push eax
|
||||||
@@ -35,8 +35,8 @@ _lock_loop0:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
;releases a lock
|
;releases a lock
|
||||||
[global _unlock]
|
[global unlock]
|
||||||
_unlock:
|
unlock:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push esi
|
push esi
|
||||||
@@ -50,15 +50,15 @@ _unlock:
|
|||||||
|
|
||||||
;returns the value in the CR0 register
|
;returns the value in the CR0 register
|
||||||
;extern dword read_cr0();
|
;extern dword read_cr0();
|
||||||
[global _read_cr0]
|
[global read_cr0]
|
||||||
_read_cr0:
|
read_cr0:
|
||||||
mov eax, cr0;
|
mov eax, cr0;
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;stores the parameter to the CR0 register
|
;stores the parameter to the CR0 register
|
||||||
;extern dword write_cr0(dword cr0);
|
;extern dword write_cr0(dword cr0);
|
||||||
[global _write_cr0]
|
[global write_cr0]
|
||||||
_write_cr0:
|
write_cr0:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
mov eax, [ebp+8]
|
mov eax, [ebp+8]
|
||||||
@@ -68,8 +68,8 @@ _write_cr0:
|
|||||||
|
|
||||||
;returns the value in the CR2 register
|
;returns the value in the CR2 register
|
||||||
;extern dword read_cr2();
|
;extern dword read_cr2();
|
||||||
[global _read_cr2]
|
[global read_cr2]
|
||||||
_read_cr2:
|
read_cr2:
|
||||||
mov eax, cr2;
|
mov eax, cr2;
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@@ -77,16 +77,16 @@ _read_cr2:
|
|||||||
|
|
||||||
;returns the value in the CR3 register
|
;returns the value in the CR3 register
|
||||||
;extern dword read_cr3();
|
;extern dword read_cr3();
|
||||||
[global _read_cr3]
|
[global read_cr3]
|
||||||
_read_cr3:
|
read_cr3:
|
||||||
mov eax, cr3;
|
mov eax, cr3;
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;stores the parameter to the CR3 register
|
;stores the parameter to the CR3 register
|
||||||
;extern dword write_cr3(dword cr3);
|
;extern dword write_cr3(dword cr3);
|
||||||
[global _write_cr3]
|
[global write_cr3]
|
||||||
_write_cr3:
|
write_cr3:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
mov eax, [ebp+8]
|
mov eax, [ebp+8]
|
||||||
@@ -96,16 +96,16 @@ _write_cr3:
|
|||||||
|
|
||||||
|
|
||||||
; read ss register
|
; read ss register
|
||||||
[global _read_ss]
|
[global read_ss]
|
||||||
_read_ss:
|
read_ss:
|
||||||
mov ax, ss
|
mov ax, ss
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;copies a string from the source to the destination parameter
|
;copies a string from the source to the destination parameter
|
||||||
;extern void strcpy(char *dest, char *src);
|
;extern void strcpy(char *dest, char *src);
|
||||||
[global _strcpy]
|
[global strcpy]
|
||||||
_strcpy:
|
strcpy:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push esi
|
push esi
|
||||||
@@ -124,8 +124,8 @@ strcpyloop:
|
|||||||
|
|
||||||
;copies memory of n bytes from src to destination
|
;copies memory of n bytes from src to destination
|
||||||
;void memcpy(void *dest, void *src, dword n);
|
;void memcpy(void *dest, void *src, dword n);
|
||||||
[global _memcpy]
|
[global memcpy]
|
||||||
_memcpy:
|
memcpy:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push esi
|
push esi
|
||||||
@@ -147,8 +147,8 @@ _memcpy:
|
|||||||
|
|
||||||
;copies memory of n words (n*2 bytes) from src to destination
|
;copies memory of n words (n*2 bytes) from src to destination
|
||||||
;void memcpyw(void *dest, void *src, dword n);
|
;void memcpyw(void *dest, void *src, dword n);
|
||||||
[global _memcpyw]
|
[global memcpyw]
|
||||||
_memcpyw:
|
memcpyw:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push esi
|
push esi
|
||||||
@@ -170,8 +170,8 @@ _memcpyw:
|
|||||||
|
|
||||||
;copies memory of n dwords (n*4 bytes) from src to destination
|
;copies memory of n dwords (n*4 bytes) from src to destination
|
||||||
;void memcpyd(void *dest, void *src, dword n);
|
;void memcpyd(void *dest, void *src, dword n);
|
||||||
[global _memcpyd]
|
[global memcpyd]
|
||||||
_memcpyd:
|
memcpyd:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push esi
|
push esi
|
||||||
@@ -193,8 +193,8 @@ _memcpyd:
|
|||||||
|
|
||||||
;sets num bytes at buffer to the value of c
|
;sets num bytes at buffer to the value of c
|
||||||
;void *memset(void *buffer, int c, int num);
|
;void *memset(void *buffer, int c, int num);
|
||||||
[global _memset]
|
[global memset]
|
||||||
_memset:
|
memset:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push edi
|
push edi
|
||||||
@@ -215,8 +215,8 @@ _memset:
|
|||||||
|
|
||||||
;sets num words at buffer to the value of c
|
;sets num words at buffer to the value of c
|
||||||
;void *memsetw(void *buffer, int c, int num);
|
;void *memsetw(void *buffer, int c, int num);
|
||||||
[global _memsetw]
|
[global memsetw]
|
||||||
_memsetw:
|
memsetw:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push edi
|
push edi
|
||||||
@@ -237,8 +237,8 @@ _memsetw:
|
|||||||
|
|
||||||
;sets num dwords at buffer to the value of c
|
;sets num dwords at buffer to the value of c
|
||||||
;void *memsetd(void *buffer, int c, int num);
|
;void *memsetd(void *buffer, int c, int num);
|
||||||
[global _memsetd]
|
[global memsetd]
|
||||||
_memsetd:
|
memsetd:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push edi
|
push edi
|
||||||
@@ -259,8 +259,8 @@ _memsetd:
|
|||||||
|
|
||||||
;returns the number of characters in a string
|
;returns the number of characters in a string
|
||||||
;extern dword strlen(char *str);
|
;extern dword strlen(char *str);
|
||||||
[global _strlen]
|
[global strlen]
|
||||||
_strlen:
|
strlen:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push esi
|
push esi
|
||||||
@@ -284,8 +284,8 @@ strlendone:
|
|||||||
;this function invalidates the page directory/table entry that
|
;this function invalidates the page directory/table entry that
|
||||||
; would be used to access the memory address given in the parameter
|
; would be used to access the memory address given in the parameter
|
||||||
;extern void invlpg_(dword addr);
|
;extern void invlpg_(dword addr);
|
||||||
[global _invlpg_]
|
[global invlpg_]
|
||||||
_invlpg_:
|
invlpg_:
|
||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
invlpg [eax]
|
invlpg [eax]
|
||||||
ret
|
ret
|
||||||
@@ -294,8 +294,8 @@ _invlpg_:
|
|||||||
;
|
;
|
||||||
;void writeCursorPosition(word pos)
|
;void writeCursorPosition(word pos)
|
||||||
;
|
;
|
||||||
[global _writeCursorPosition]
|
[global writeCursorPosition]
|
||||||
_writeCursorPosition:
|
writeCursorPosition:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
|
|
||||||
@@ -333,8 +333,8 @@ _writeCursorPosition:
|
|||||||
;
|
;
|
||||||
;word getCursorPosition()
|
;word getCursorPosition()
|
||||||
;
|
;
|
||||||
[global _getCursorPosition]
|
[global getCursorPosition]
|
||||||
_getCursorPosition:
|
getCursorPosition:
|
||||||
push ebx
|
push ebx
|
||||||
push edx
|
push edx
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
|
|
||||||
/* lang.asm */
|
/* lang.asm */
|
||||||
void lock(lock_t *addr);
|
void lockit(lock_t *addr);
|
||||||
void unlock(lock_t *addr);
|
void unlock(lock_t *addr);
|
||||||
u32_t read_cr0();
|
u32_t read_cr0();
|
||||||
u32_t write_cr0(u32_t cr0);
|
u32_t write_cr0(u32_t cr0);
|
||||||
|
|||||||
+100
-134
@@ -15,6 +15,8 @@ template<typename type>
|
|||||||
class vector
|
class vector
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
typedef type * type_ptr_t;
|
||||||
|
|
||||||
/* Pointers to vector elements */
|
/* Pointers to vector elements */
|
||||||
type **myData;
|
type **myData;
|
||||||
|
|
||||||
@@ -25,157 +27,121 @@ protected:
|
|||||||
unsigned int myAllocated;
|
unsigned int myAllocated;
|
||||||
|
|
||||||
/* Causes the vector to double in its allocated size */
|
/* Causes the vector to double in its allocated size */
|
||||||
void grow();
|
void grow()
|
||||||
|
{
|
||||||
|
myAllocated <<= 1;
|
||||||
|
if (myAllocated == 0)
|
||||||
|
myAllocated = 1;
|
||||||
|
type **data_new = new type_ptr_t[myAllocated];
|
||||||
|
for (unsigned int i = 0; i < mySize; i++)
|
||||||
|
data_new[i] = myData[i];
|
||||||
|
if (myData)
|
||||||
|
delete[] myData;
|
||||||
|
myData = data_new;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Constructors/Destructor */
|
/* Constructors/Destructor */
|
||||||
vector<type>();
|
vector<type>()
|
||||||
vector<type>(unsigned int size);
|
{
|
||||||
vector<type>(const vector<type> & v1);
|
myData = NULL;
|
||||||
~vector<type>();
|
mySize = 0;
|
||||||
|
myAllocated = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<type>(unsigned int size)
|
||||||
|
{
|
||||||
|
myData = new type_ptr_t[size];
|
||||||
|
mySize = 0;
|
||||||
|
myAllocated = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<type>(const vector<type> & v1)
|
||||||
|
{
|
||||||
|
mySize = v1.mySize;
|
||||||
|
myAllocated = v1.myAllocated;
|
||||||
|
myData = new type_ptr_t[myAllocated];
|
||||||
|
for (u32_t i = 0; i < mySize; i++)
|
||||||
|
myData[i] = new type(*v1.myData[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
~vector<type>()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < mySize; i++)
|
||||||
|
delete myData[i];
|
||||||
|
delete[] myData;
|
||||||
|
}
|
||||||
|
|
||||||
/* Assignment operator */
|
/* Assignment operator */
|
||||||
vector<type> & operator=(const vector<type> & v1);
|
vector<type> & operator=(const vector<type> & v1)
|
||||||
|
{
|
||||||
|
mySize = v1.mySize;
|
||||||
|
myAllocated = v1.myAllocated;
|
||||||
|
myData = new type_ptr_t[myAllocated];
|
||||||
|
for (u32_t i = 0; i < mySize; i++)
|
||||||
|
myData[i] = new type(*v1.myData[i]);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns the size of the vector */
|
/* Returns the size of the vector */
|
||||||
unsigned int size() const;
|
unsigned int size() const
|
||||||
|
{
|
||||||
|
return mySize;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add an element to the end of the vector */
|
/* Add an element to the end of the vector */
|
||||||
vector<type> & add(type elem);
|
vector<type> & add(type elem)
|
||||||
|
{
|
||||||
|
while (mySize >= myAllocated)
|
||||||
|
grow();
|
||||||
|
myData[mySize++] = new type(elem);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove an element from the vector */
|
/* Remove an element from the vector */
|
||||||
vector<type> & remove(unsigned int index);
|
vector<type> & remove(unsigned int index)
|
||||||
|
{
|
||||||
|
if (index < mySize)
|
||||||
|
{
|
||||||
|
delete myData[index];
|
||||||
|
for (unsigned int i = index; i < (mySize - 1); i++)
|
||||||
|
myData[i] = myData[i+1];
|
||||||
|
mySize--;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/* Insert an element into a position in the vector */
|
/* Insert an element into a position in the vector */
|
||||||
vector<type> & insert(type elem, unsigned int position);
|
vector<type> & insert(type elem, unsigned int position)
|
||||||
|
{
|
||||||
|
if (position <= mySize)
|
||||||
|
{
|
||||||
|
if (mySize >= myAllocated)
|
||||||
|
grow();
|
||||||
|
for (unsigned int i = mySize; i > position; i--)
|
||||||
|
myData[i] = myData[i-1];
|
||||||
|
myData[position] = new type(elem);
|
||||||
|
mySize++;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/* Direct access operators */
|
/* Direct access operators */
|
||||||
const type & operator[](unsigned int index) const;
|
const type & operator[](unsigned int index) const
|
||||||
type & operator[](unsigned int index);
|
{
|
||||||
|
return *myData[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
type & operator[](unsigned int index)
|
||||||
|
{
|
||||||
|
return *myData[index];
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns pointer to data */
|
/* Returns pointer to data */
|
||||||
type **data();
|
type **data()
|
||||||
|
{
|
||||||
|
return myData;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
vector<type>::vector<type>()
|
|
||||||
{
|
|
||||||
myData = NULL;
|
|
||||||
mySize = 0;
|
|
||||||
myAllocated = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
vector<type>::vector<type>(unsigned int size)
|
|
||||||
{
|
|
||||||
myData = new (type *)[size];
|
|
||||||
mySize = 0;
|
|
||||||
myAllocated = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
vector<type>::vector<type>(const vector<type> & v1)
|
|
||||||
{
|
|
||||||
mySize = v1.mySize;
|
|
||||||
myAllocated = v1.myAllocated;
|
|
||||||
myData = new (type *)[myAllocated];
|
|
||||||
for (u32_t i = 0; i < mySize; i++)
|
|
||||||
myData[i] = new type(*v1.myData[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
vector<type>::~vector<type>()
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < mySize; i++)
|
|
||||||
delete myData[i];
|
|
||||||
delete[] myData;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
vector<type> & vector<type>::operator=(const vector<type> & v1)
|
|
||||||
{
|
|
||||||
mySize = v1.mySize;
|
|
||||||
myAllocated = v1.myAllocated;
|
|
||||||
myData = new (type *)[myAllocated];
|
|
||||||
for (u32_t i = 0; i < mySize; i++)
|
|
||||||
myData[i] = new type(*v1.myData[i]);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
u32_t vector<type>::size() const
|
|
||||||
{
|
|
||||||
return mySize;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
const type & vector<type>::operator[](unsigned int index) const
|
|
||||||
{
|
|
||||||
return *myData[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
type & vector<type>::operator[](unsigned int index)
|
|
||||||
{
|
|
||||||
return *myData[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
vector<type> & vector<type>::add(type elem)
|
|
||||||
{
|
|
||||||
while (mySize >= myAllocated)
|
|
||||||
grow();
|
|
||||||
myData[mySize++] = new type(elem);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
void vector<type>::grow()
|
|
||||||
{
|
|
||||||
myAllocated <<= 1;
|
|
||||||
if (myAllocated == 0)
|
|
||||||
myAllocated = 1;
|
|
||||||
type **data_new = new (type *)[myAllocated];
|
|
||||||
for (unsigned int i = 0; i < mySize; i++)
|
|
||||||
data_new[i] = myData[i];
|
|
||||||
if (myData)
|
|
||||||
delete[] myData;
|
|
||||||
myData = data_new;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
vector<type> & vector<type>::remove(unsigned int index)
|
|
||||||
{
|
|
||||||
if (index < mySize)
|
|
||||||
{
|
|
||||||
delete myData[index];
|
|
||||||
for (unsigned int i = index; i < (mySize - 1); i++)
|
|
||||||
myData[i] = myData[i+1];
|
|
||||||
mySize--;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
vector<type> & vector<type>::insert(type elem, unsigned int position)
|
|
||||||
{
|
|
||||||
if (position <= mySize)
|
|
||||||
{
|
|
||||||
if (mySize >= myAllocated)
|
|
||||||
grow();
|
|
||||||
for (unsigned int i = mySize; i > position; i--)
|
|
||||||
myData[i] = myData[i-1];
|
|
||||||
myData[position] = new type(elem);
|
|
||||||
mySize++;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
type **vector<type>::data()
|
|
||||||
{
|
|
||||||
return myData;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+4
-3
@@ -1,10 +1,11 @@
|
|||||||
OUTPUT_FORMAT("binary")
|
OUTPUT_FORMAT("binary")
|
||||||
ENTRY(_start)
|
ENTRY(start)
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
.text 0xC0108000 : {
|
.text 0xC0108000 : {
|
||||||
code = .; _code = .; __code = .;
|
code = .; _code = .; __code = .;
|
||||||
*(.text)
|
*(.text)
|
||||||
|
*(.eh_frame*)
|
||||||
}
|
}
|
||||||
.gnulinkonce : {
|
.gnulinkonce : {
|
||||||
*(.gnu.linkonce*)
|
*(.gnu.linkonce*)
|
||||||
@@ -12,8 +13,8 @@ SECTIONS
|
|||||||
}
|
}
|
||||||
.data : {
|
.data : {
|
||||||
data = .; _data = .; __data = .;
|
data = .; _data = .; __data = .;
|
||||||
*(.data)
|
*(.data*)
|
||||||
*(.rodata)
|
*(.rodata*)
|
||||||
. = ALIGN(4096);
|
. = ALIGN(4096);
|
||||||
}
|
}
|
||||||
.bss : {
|
.bss : {
|
||||||
|
|||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
HOS - Holtrop's Operating System
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
HOS is (in the process of becoming) a 32-bit, protected mode, graphical, multitasking operating system.
|
||||||
|
It was written by me, Josh Holtrop, with help from a few others along the way.
|
||||||
|
|
||||||
|
|
||||||
|
Goals: (A = accomplished, P = in progress, T = todo)
|
||||||
|
----------------------------------------------------
|
||||||
|
(A) Custom bootloader to load kernel from FAT-formatted boot media, options for video mode/ram disk
|
||||||
|
(A) Multiboot compliance - kernel can be loaded by GRUB
|
||||||
|
(A) 32-bit protected mode environment
|
||||||
|
(A) VESA Support for graphics modes
|
||||||
|
(A) PS/2 keyboard & mouse drivers
|
||||||
|
(A) Utilize x86's paging architecture for virtual memory management
|
||||||
|
|
||||||
|
(P) Console Manager
|
||||||
|
(P) VFS abstraction layer for a single file system
|
||||||
|
(P) ram disk driver
|
||||||
|
(P) devfs file system driver
|
||||||
|
(P) ext2 file system support
|
||||||
|
|
||||||
|
(T) vfat file system support
|
||||||
|
(T) Multitasking support
|
||||||
|
(T) HASH command shell
|
||||||
|
(T) Window Manager
|
||||||
|
(T) Various other utilities/applications
|
||||||
|
(T) Hard Drive (ATA) driver
|
||||||
|
(T) cdrom (ATAPI) driver
|
||||||
|
|
||||||
|
|
||||||
|
Change Log
|
||||||
|
----------
|
||||||
|
0.16
|
||||||
|
12/16/04 - initrd going to be loaded as a gzipped ext2 image (kernel module) - faster loading!
|
||||||
|
|
||||||
|
0.15
|
||||||
|
07/10/04 - Multiboot support added, loadable by GRUB
|
||||||
|
|
||||||
|
0.14
|
||||||
|
05/21/04 - C++ support in kernel, can use classes & templates
|
||||||
|
04/04/04 - video_line function for diagonal lines
|
||||||
|
03/16/04 - new VFS design with support for a loop device
|
||||||
|
03/01/04 - Thanks to Ben Meyer for helping me get a Makefile working and building on linux to work!
|
||||||
|
|
||||||
|
0.13
|
||||||
|
01/26/04 - functions added to read/write CMOS clock date and time
|
||||||
|
01/19/04 - fixed bug GDTR/IDTR pointing to physical rather than linear table base address
|
||||||
|
01/07/04 - fixed bug not reading sectors correctly from floppy
|
||||||
|
12/28/03 - fixed bug not storing eax on interrupt
|
||||||
|
12/25/03 - fixed bug in mm_palloc()
|
||||||
|
12/25/03 - incorporated output functions as regular functions rather than as part of a linked library
|
||||||
|
12/23/03 - re-written physical memory manager using bitmap instead of stack
|
||||||
|
12/22/03 - kernel relocated to 3gb linear / 1mb+24kb physical to allow for app. address space
|
||||||
|
|
||||||
|
0.12
|
||||||
|
12/21/03 - sample bmp loader tested, works (tests loading a kernel of size ~ 932kb)
|
||||||
|
12/20/03 - GDT/IDT now located at 1mb physical, before kernel
|
||||||
|
10/30/03 - turns floppy motor off
|
||||||
|
10/30/03 - keyboard LEDs working
|
||||||
|
10/29/03 - paging functions working
|
||||||
|
10/15/03 - physical memory management page allocators working
|
||||||
|
|
||||||
|
0.11
|
||||||
|
10/09/03 - PS/2 mouse driver
|
||||||
|
|
||||||
|
0.10
|
||||||
|
09/11/03 - Rewritten C and assembly kernel with VESA GUI mode support, keyboard driver
|
||||||
|
|
||||||
|
0.05
|
||||||
|
05/14/03 - HGUI24/HGUI32 commands finished for testing GUI on both 24bpp and 32bpp graphics cards
|
||||||
|
05/14/03 - first web release!
|
||||||
|
|
||||||
|
0.04
|
||||||
|
03/09/03 - added VM shortcut command
|
||||||
|
03/09/03 - press up to fill retrieve last inputted command for Nate Scholten
|
||||||
|
03/08/03 - press clear to clear console input
|
||||||
|
03/07/03 - added "shortcut" commands PC, IC, ? for Nate Scholten
|
||||||
|
03/06/03 - added PROMPTC, INPUTC commands
|
||||||
|
|
||||||
|
0.03
|
||||||
|
12/30/02 - Command Line Interface working, accepting basic commands
|
||||||
|
|
||||||
|
0.02
|
||||||
|
12/11/02 - Assembly bootsector can load stage2 ("console")
|
||||||
|
|
||||||
|
0.01
|
||||||
|
12/01/02 - Real mode assembly bootsector boots from floppy disk successfully
|
||||||
|
|
||||||
Reference in new issue
Block a user