Added include folder with hos_types.h and hos_defines.h

Added mm build subdir with mm.c
Updated subdir.mak to build $(subdir)_all.o instead of $(subdir).o
Updated main Makefile to pass SUBDIR in to subdirectory builds, add $(HOS_TOPLEVEL)/include to compiler include path, and made the linker write a map file
Updated boot.asm to use the page_directory symbol from the .bss section defined in mm.o as its temporary stack area

git-svn-id: svn://anubis/hos/trunk@22 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
josh 2009-06-29 19:55:50 +00:00
parent fb807847bf
commit 90e03d4f95
8 changed files with 53 additions and 12 deletions

View File

@ -20,12 +20,12 @@ WD := $(shell pwd)
export HOS_TOPLEVEL := $(WD) export HOS_TOPLEVEL := $(WD)
LDSCRIPT := link.ld LDSCRIPT := link.ld
KERNEL := hos KERNEL := hos
export CPPFLAGS := -I$(WD)/include export CPPFLAGS := -I$(HOS_TOPLEVEL) -I$(HOS_TOPLEVEL)/include
export CFLAGS := -Wall -O2 export CFLAGS := -Wall -O2
export CXXFLAGS := -Wall -O2 export CXXFLAGS := -Wall -O2
export LDFLAGS := -T $(LDSCRIPT) export LDFLAGS := -T $(LDSCRIPT) -Map $(KERNEL).map
SUBDIRS := boot SUBDIRS := boot mm
SUBDIRS_clean := $(SUBDIRS:%=%.clean) SUBDIRS_clean := $(SUBDIRS:%=%.clean)
.PHONY: all .PHONY: all
@ -35,11 +35,11 @@ $(KERNEL).gz: $(KERNEL)
gzip -c $< > $@ gzip -c $< > $@
$(KERNEL): $(SUBDIRS) $(KERNEL): $(SUBDIRS)
$(LD) $(LDFLAGS) -o $@ $(foreach subdir,$(SUBDIRS),$(subdir)/$(subdir).o) $(LD) $(LDFLAGS) -o $@ $(foreach subdir,$(SUBDIRS),$(subdir)/$(subdir)_all.o)
.PHONY: $(SUBDIRS) .PHONY: $(SUBDIRS)
$(SUBDIRS): $(SUBDIRS):
$(MAKE) -C $@ $(MAKE) -C $@ SUBDIR=$@
.PHONY: clean .PHONY: clean
clean: $(SUBDIRS_clean) clean: $(SUBDIRS_clean)

View File

@ -9,16 +9,13 @@
%define VIRTUAL_OFFSET 0xE0000000 ; kernel virtual addr %define VIRTUAL_OFFSET 0xE0000000 ; kernel virtual addr
%define TEMPORARY_STACK_PHYSICAL 0x01000000-4 ; top of first 16MB
%define TEMPORARY_STACK_VIRTUAL TEMPORARY_STACK_PHYSICAL + VIRTUAL_OFFSET
%define PAGE_SIZE 0x1000 ; 4KB pages %define PAGE_SIZE 0x1000 ; 4KB pages
; Symbols from the linker ; Symbols from the linker
extern _end, _bss extern _end, _bss
; Symbols from C ; Symbols from C
extern k_mbsave extern k_mbsave, page_directory
;------------------------------------------------------- ;-------------------------------------------------------
[section .text] [section .text]
@ -66,7 +63,7 @@ segmented_start:
mov es, cx mov es, cx
mov gs, cx mov gs, cx
mov fs, cx mov fs, cx
mov esp, TEMPORARY_STACK_VIRTUAL-4 ; set up temporary stack space mov esp, page_directory+PAGE_SIZE-4 ; set up temporary stack space
mov ax, 0x0700 + 'b' mov ax, 0x0700 + 'b'
mov [VIRTUAL_OFFSET+0xB8000+160*8+1*2], ax mov [VIRTUAL_OFFSET+0xB8000+160*8+1*2], ax

View File

@ -0,0 +1,7 @@
#ifndef HOS_DEFINES_H
#define HOS_DEFINES_H
#define PAGE_SIZE 4096
#endif

View File

@ -0,0 +1,14 @@
#ifndef HOS_TYPES_H
#define HOS_TYPES_H
typedef unsigned char u8_t;
typedef signed char s8_t;
typedef unsigned short u16_t;
typedef signed short s16_t;
typedef unsigned int u32_t;
typedef signed int s32_t;
typedef unsigned long long u64_t;
typedef signed long long s64_t;
#endif

2
kernel/mm/Makefile Normal file
View File

@ -0,0 +1,2 @@
include $(HOS_TOPLEVEL)/subdir.mak

4
kernel/mm/mm.c Normal file
View File

@ -0,0 +1,4 @@
#include "mm.h"
pagedirectory_t page_directory __attribute__ ((aligned (4096)));

16
kernel/mm/mm.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef MM_H
#define MM_H MM_H
#include "hos_types.h"
#include "hos_defines.h"
typedef u32_t pagedirectory_entry_t;
typedef pagedirectory_entry_t
pagedirectory_t[PAGE_SIZE / sizeof(pagedirectory_entry_t)];
extern pagedirectory_t page_directory;
#endif

View File

@ -4,10 +4,11 @@ COBJS := $(patsubst %.c,%.o,$(wildcard *.c))
CXXOBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) CXXOBJS := $(patsubst %.cc,%.o,$(wildcard *.cc))
CDEPS := $(COBJS:.o=.dep) CDEPS := $(COBJS:.o=.dep)
CXXDEPS := $(CXXOBJS:.o=.dep) CXXDEPS := $(CXXOBJS:.o=.dep)
OUTPUT_FILE := $(SUBDIR)_all.o
all: $(SUBDIR).o all: $(OUTPUT_FILE)
$(SUBDIR).o: $(ASMOBJS) $(COBJS) $(CXXOBJS) $(OUTPUT_FILE): $(ASMOBJS) $(COBJS) $(CXXOBJS)
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
%.o: %.asm %.o: %.asm