Merge branch 'master' of git.lfbs.rwth-aachen.de:metalsvm_private
This commit is contained in:
commit
0b5f83392f
3 changed files with 228 additions and 1 deletions
|
@ -35,7 +35,6 @@ RM = rm -rf
|
|||
NASM = nasm
|
||||
# For 64bit code, you have to use qemu-system-x86_64
|
||||
QEMU = qemu-system-i386
|
||||
EMU = qemu
|
||||
GDB = gdb
|
||||
|
||||
# For 64bit support, you have to define -felf64 instead of -felf32
|
||||
|
|
137
Makefile.scc
Normal file
137
Makefile.scc
Normal file
|
@ -0,0 +1,137 @@
|
|||
TOPDIR = $(shell pwd)
|
||||
ARCH = x86
|
||||
# For 64bit support, you have define BIT as 64
|
||||
BIT=32
|
||||
NAME = metalsvm
|
||||
LWIPDIRS = lwip/src/arch lwip/src/api lwip/src/core lwip/src/core/ipv4 lwip/src/netif
|
||||
DRIVERDIRS = drivers/net drivers/char
|
||||
KERNDIRS = libkern kernel mm fs apps arch/$(ARCH)/kernel arch/$(ARCH)/mm arch/$(ARCH)/scc $(LWIPDIRS) $(DRIVERDIRS)
|
||||
SUBDIRS = $(KERNDIRS)
|
||||
STACKPROT = -fno-stack-protector
|
||||
|
||||
# Set your own cross compiler tool chain prefix here
|
||||
CROSSCOMPREFIX =
|
||||
|
||||
# Uncomment both lines if compiling for the SCC!
|
||||
CROSSCOMPREFIX = i386-unknown-linux-gnu-
|
||||
STACKPROT =
|
||||
|
||||
CC_FOR_TARGET = $(CROSSCOMPREFIX)gcc
|
||||
CXX_FOR_TARGET = $(CROSSCOMPREFIX)g++
|
||||
GCC_FOR_TARGET = $(CROSSCOMPREFIX)gcc
|
||||
CPP_FOR_TARGET = $(CROSSCOMPREFIX)cpp
|
||||
AR_FOR_TARGET = $(CROSSCOMPREFIX)ar
|
||||
AS_FOR_TARGET = $(CROSSCOMPREFIX)as
|
||||
LD_FOR_TARGET = $(CROSSCOMPREFIX)ld
|
||||
NM_FOR_TARGET = $(CROSSCOMPREFIX)nm
|
||||
OBJDUMP_FOR_TARGET = $(CROSSCOMPREFIX)objdump
|
||||
OBJCOPY_FOR_TARGET = $(CROSSCOMPREFIX)objcopy
|
||||
RANLIB_FOR_TARGET = $(CROSSCOMPREFIX)ranlib
|
||||
STRIP_FOR_TARGET = $(CROSSCOMPREFIX)strip
|
||||
READELF_FOR_TARGET = $(CROSSCOMPREFIX)readelf
|
||||
|
||||
MAKE = make
|
||||
RM = rm -rf
|
||||
NASM = nasm
|
||||
# For 64bit code, you have to use qemu-system-x86_64
|
||||
QEMU = qemu-system-i386
|
||||
GDB = gdb
|
||||
|
||||
# For 64bit support, you have to define -felf64 instead of -felf32
|
||||
NASMFLAGS = -felf32 -g -i$(TOPDIR)/include/metalsvm/
|
||||
INCLUDE = -I$(TOPDIR)/include -I$(TOPDIR)/arch/$(ARCH)/include -I$(TOPDIR)/lwip/src/include -I$(TOPDIR)/lwip/src/include/ipv4 -I$(TOPDIR)/drivers
|
||||
# For 64bit support, you have to define "-m64 -mno-red-zone" instead of "-m32 -march=i586"
|
||||
# Compiler options for final code
|
||||
CFLAGS = -g -m32 -march=i586 -Wall -O2 -fstrength-reduce -fomit-frame-pointer -finline-functions -ffreestanding $(INCLUDE) $(STACKPROT)
|
||||
# Compiler options for debuging
|
||||
#CFLAGS = -g -O -m32 -march=i586 -Wall -DWITH_FRAME_POINTER -ffreestanding $(INCLUDE) $(STACKPROT)
|
||||
ARFLAGS = rsv
|
||||
LDFLAGS = -T link$(BIT).ld -z max-page-size=4096 --defsym __BUILD_DATE=$(shell date +'%Y%m%d') --defsym __BUILD_TIME=$(shell date +'%H%M%S')
|
||||
STRIP_DEBUG = --strip-debug
|
||||
KEEP_DEBUG = --only-keep-debug
|
||||
OUTPUT_FORMAT = -O elf32-i386
|
||||
# For 64bit support, you have to define -m64 instead of "-m32 -march=i586"
|
||||
CFLAGS_FOR_NEWLIB = -m32 -march=i586 -O2 $(STACKPROT)
|
||||
# For 64bit support, you have to define -m64 instead of "-m32 -march=i586"
|
||||
LDFLAGS_FOR_NEWLIB = -m32 -march=i586
|
||||
# For 64bit support, you have to define -m64 instead of "-m32"
|
||||
CFLAGS_FOR_TOOLS = -m32 -O2 -Wall
|
||||
LDFLAGS_FOR_TOOLS =
|
||||
# For 64bit support, you have to define -felf64 instead of -felf32
|
||||
NASMFLAGS_FOR_NEWLIB = -felf32
|
||||
|
||||
# Prettify output
|
||||
V = 0
|
||||
ifeq ($V,0)
|
||||
Q = @
|
||||
P = > /dev/null
|
||||
endif
|
||||
|
||||
default: all
|
||||
|
||||
all: newlib tools $(NAME).elf
|
||||
|
||||
newlib:
|
||||
$(MAKE) ARCH=$(ARCH) BIT=$(BIT) LDFLAGS="$(LDFLAGS_FOR_NEWLIB)" CFLAGS="$(CFLAGS_FOR_NEWLIB)" NASMFLAGS="$(NASMFLAGS_FOR_NEWLIB)" CC_FOR_TARGET=$(CC_FOR_TARGET) \
|
||||
CXX_FOR_TARGET=$(CXX_FOR_TARGET) \
|
||||
GCC_FOR_TARGET=$(GCC_FOR_TARGET) \
|
||||
AR_FOR_TARGET=$(AR_FOR_TARGET) \
|
||||
AS_FOR_TARGET=$(AS_FOR_TARGET) \
|
||||
LD_FOR_TARGET=$(LD_FOR_TARGET) \
|
||||
NM_FOR_TARGET=$(NM_FOR_TARGET) \
|
||||
OBJDUMP_FOR_TARGET=$(OBJDUMP_FOR_TARGET) \
|
||||
OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) \
|
||||
RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET) \
|
||||
STRIP_FOR_TARGET=$(STRIP_FOR_TARGET) \
|
||||
READELF_FOR_TARGET=$(READELF_FOR_TARGET) -C newlib
|
||||
|
||||
tools:
|
||||
$(MAKE) CFLAGS="$(CFLAGS_FOR_TOOLS)" LDFLAGS="$(LDFLAGS_FOR_TOOLS)" -C tools
|
||||
|
||||
$(NAME).elf:
|
||||
$Q$(LD_FOR_TARGET) $(LDFLAGS) -o $(NAME).elf $^
|
||||
@echo [OBJCOPY] $(NAME).sym
|
||||
$Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $(NAME).elf $(NAME).sym
|
||||
@echo [OBJCOPY] $(NAME).elf
|
||||
$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $(OUTPUT_FORMAT) $(NAME).elf
|
||||
|
||||
qemu: newlib tools $(NAME).elf
|
||||
$(QEMU) -monitor stdio -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:4711 -net dump -kernel metalsvm.elf -initrd tools/initrd.img
|
||||
|
||||
qemudbg: newlib tools $(NAME).elf
|
||||
$(QEMU) -s -S -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:4711 -net dump -kernel metalsvm.elf -initrd tools/initrd.img
|
||||
|
||||
gdb: $(NAME).elf
|
||||
make qemudbg > /dev/null &
|
||||
$(GDB) -x script.gdb
|
||||
|
||||
clean:
|
||||
$Q$(RM) $(NAME).elf $(NAME).sym *~
|
||||
$Q$(MAKE) -C tools clean
|
||||
@echo Cleaned.
|
||||
|
||||
veryclean: clean
|
||||
$Q$(MAKE) -C newlib veryclean
|
||||
@echo Very cleaned
|
||||
|
||||
#depend:
|
||||
# for i in $(SUBDIRS); do $(MAKE) -k -C $$i depend; done
|
||||
|
||||
%.o : %.c
|
||||
@echo [CC] $@
|
||||
$Q$(CC_FOR_TARGET) -c -D__KERNEL__ $(CFLAGS) -o $@ $<
|
||||
@echo [DEP] $*.dep
|
||||
$Q$(CPP_FOR_TARGET) -MF $*.dep -MT $*.o -MM -D__KERNEL__ $(CFLAGS) $<
|
||||
|
||||
include/metalsvm/config.inc: include/metalsvm/config.h
|
||||
@echo "; This file is generated automatically from the config.h file." > include/metalsvm/config.inc
|
||||
@echo "; Before editing this, you should consider editing config.h." >> include/metalsvm/config.inc
|
||||
@awk '/^#define MAX_CORES/{ print "%define MAX_CORES", $$3 }' include/metalsvm/config.h >> include/metalsvm/config.inc
|
||||
|
||||
%.o : %.asm include/metalsvm/config.inc
|
||||
@echo [ASM] $@
|
||||
$Q$(NASM) $(NASMFLAGS) -o $@ $<
|
||||
|
||||
.PHONY: default all clean emu gdb newlib tools
|
||||
|
||||
include $(addsuffix /Makefile,$(SUBDIRS))
|
91
include/metalsvm/config.h.scc
Normal file
91
include/metalsvm/config.h.scc
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
|
||||
* RWTH Aachen University
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of MetalSVM.
|
||||
*/
|
||||
|
||||
#ifndef __CONFIG_H__
|
||||
#define __CONFIG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define METALSVM_VERSION "0.1"
|
||||
#define MAX_TASKS 16
|
||||
#define MAX_CORES 1
|
||||
#define MAX_FNAME 128
|
||||
#define DEFAULT_STACK_SIZE (32*1024)
|
||||
#define KERNEL_STACK_SIZE 8192
|
||||
#define KMSG_SIZE (128*1024)
|
||||
#define PAGE_SHIFT 12
|
||||
#define CACHE_LINE 32
|
||||
#define MAILBOX_SIZE 8
|
||||
#define TIMER_FREQ 100 /* in HZ */
|
||||
#define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */
|
||||
#define INT_SYSCALL 0x80
|
||||
#define KERNEL_SPACE (1*1024*1024*1024)
|
||||
#define VIDEO_MEM_ADDR 0xB8000 // the video memora address
|
||||
#define SMP_SETUP_ADDR 0x07000
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
/*
|
||||
* address space / (page_size * sizeof(uint8_t))
|
||||
* x86_32 => 4 GB / (4096 * 8)
|
||||
*/
|
||||
#define BITMAP_SIZE 1048576
|
||||
|
||||
//#define CONFIG_PCI
|
||||
#define CONFIG_LWIP
|
||||
//#define CONFIG_VGA
|
||||
//#define CONFIG_UART
|
||||
//#define CONFIG_KEYBOARD
|
||||
//#define CONFIG_MULTIBOOT
|
||||
#define CONFIG_ROCKCREEK
|
||||
|
||||
#ifdef CONFIG_ROCKCREEK
|
||||
#ifndef __SIZEOF_POINTER__
|
||||
#define __SIZEOF_POINTER__ 4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// RCCE specific flags
|
||||
#define SCC
|
||||
#define COPPERRIDGE
|
||||
#define MS_BAREMETAL
|
||||
//#define GORY
|
||||
//#define SHMADD
|
||||
#define SHMDBG
|
||||
//#define SHMADD_CACHEABLE
|
||||
#define SCC_BOOTINFO 0x80000
|
||||
|
||||
#define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b))
|
||||
//#define BUILTIN_EXPECT(exp, b) (exp)
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define STDCALL __attribute__((stdcall))
|
||||
|
||||
#define HAVE_ARCH_MEMSET
|
||||
#define HAVE_ARCH_MEMCPY
|
||||
#define HAVE_ARCH_STRLEN
|
||||
#define HAVE_ARCH_STRCPY
|
||||
#define HAVE_ARCH_STRNCPY
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue