1
0
포크 0

i386: Add new arch support! (woefully incomplete)

This commit is contained in:
Aaron Lindsay 2012-11-15 00:38:10 -05:00
부모 c76991b1b5
커밋 cee0ac7dda
8개의 변경된 파일201개의 추가작업 그리고 0개의 파일을 삭제

30
arch/i386/i386_main.c Normal file
파일 보기

@ -0,0 +1,30 @@
#include <stdint.h>
void main();
void i386_main(void)
{
extern uint32_t magic;
/* Uncomment the following if you want to be able to access the multiboot header */
/* extern void *mbd; */
if ( magic != 0x2BADB002 )
{
/* Something went not according to specs. Print an error */
/* message and halt, but do *not* rely on the multiboot */
/* data structure. */
}
/* You could either use multiboot.h */
/* (http://www.gnu.org/software/grub/manual/multiboot/multiboot.html#multiboot_002eh) */
/* or do your offsets yourself. The following is merely an example. */
//char * boot_loader_name =(char*) ((long*)mbd)[16];
/* Print a letter to screen to see everything is working: */
unsigned char *videoram = (unsigned char *)0xB8000;
videoram[0] = 65; /* character 'A' */
videoram[1] = 0x07; /* light grey (7) on black (0). */
main();
}

파일 보기

@ -0,0 +1,23 @@
/*
Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com>
This file is part of Aedrix.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <arch-generic/types.h>
#define arch_uint_ptr uint32

18
arch/i386/kernel.ld Normal file
파일 보기

@ -0,0 +1,18 @@
ENTRY (start)
SECTIONS
{
. = 0x00100000;
.text ALIGN (0x1000) : { *(.text*) *(.rodata*) }
.init : {
early_initcalls_start = .;
*(.earlyinitcalls*)
early_initcalls_end = .;
initcalls_start = .;
*(.driversubsysinitcalls*)
*(.deviceinitcalls*)
initcalls_end = .;
}
.data ALIGN (0x1000) : { *(.data*) }
.bss : { *(.bss*) *(COMMON*) }
}

32
arch/i386/kernel.mk Normal file
파일 보기

@ -0,0 +1,32 @@
DIRNAME := arch/i386
SUBDIRS := kernel
include $(BASEDIR)/header.mk
# Architecture-specific definitions
CROSS_COMPILE ?=
ARCH_KCFLAGS = -m32
ARCH_KLDFLAGS = -melf_i386
all: aedrix-boot.img
HD_IMAGE_SIZE := $(shell echo $$((4*1024*1024)))
HD_NUM_BLOCKS := $(shell echo $$(($(HD_IMAGE_SIZE)/4096)))
KERNEL_ARGS :=
aedrix-boot.img: aedrix-kernel.elf
@echo ' BUILD aedrix-boot.img'
$(V)dd if=/dev/zero of="$@" bs=4k count=$(HD_NUM_BLOCKS) 2>/dev/null
$(V)mkfs.vfat "$@" 1>/dev/null
$(V)syslinux "$@"
$(V)mcopy -i "$@" /usr/lib/syslinux/mboot.c32 ::mboot.c32
$(V)mcopy -i "$@" aedrix-kernel.elf ::kernel.bin
$(V)mcopy -i "$@" arch/i386/syslinux.cfg ::syslinux.cfg
OBJS_$(d) := $(d)/start.o \
$(d)/i386_main.o
KOBJS += $(OBJS_$(d))
include $(BASEDIR)/footer.mk
ARCH_QEMU_CMD = qemu-system-i386 -m 1024

파일 보기

@ -0,0 +1,10 @@
DIRNAME := kernel
SUBDIRS :=
include $(BASEDIR)/header.mk
OBJS_$(d) := $(d)/mmu.o
KOBJS += $(OBJS_$(d))
include $(BASEDIR)/footer.mk

30
arch/i386/kernel/mmu.c Normal file
파일 보기

@ -0,0 +1,30 @@
/*
Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com>
This file is part of Aedrix.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <print.h>
#include <types.h>
#include <mm.h>
void mmu_reinit() {
}
void declare_memory_region(void *lower, void *upper) {
(void)lower;
(void)upper;
}

56
arch/i386/start.S Normal file
파일 보기

@ -0,0 +1,56 @@
/*
Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com>
This file is part of Aedrix.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
.global start /* making entry point visible to linker */
/* setting up the Multiboot header - see GRUB docs for details */
.set ALIGN, 1<<0 /* align loaded modules on page boundaries */
.set MEMINFO, 1<<1 /* provide memory map */
.set FLAGS, ALIGN | MEMINFO /* this is the Multiboot 'flag' field */
.set MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */
.set CHECKSUM, -(MAGIC + FLAGS) /* checksum required */
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
/* reserve initial kernel stack space */
.set STACKSIZE, 0x4000 /* that is, 16k. */
.align 32
.lcomm stack, STACKSIZE /* reserve 16k stack on a doubleword boundary */
.comm mbd, 4 /* we will use this in i386_main */
.comm magic, 4 /* we will use this in i386_main */
start:
movl $(stack + STACKSIZE), %esp /* set up the stack */
movl %eax, magic /* Multiboot magic number */
movl %ebx, mbd /* Multiboot data structure */
call i386_main /* call kernel proper */
cli
hang:
hlt /* halt machine should kernel return */
jmp hang
.globl atags_ptr
atags_ptr:
.word 0

2
arch/i386/syslinux.cfg Normal file
파일 보기

@ -0,0 +1,2 @@
TIMEOUT 1
DEFAULT mboot.c32 kernel.bin ''