mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Changed the virt-to-phys debug breakpoint name to break_virtual
Changed l4id_t type to integer to recognise negative id values like L4_ANYTHREAD. Added an extremely simple script that cleans and builds everything in right order. Increased boot pmds by one: This is due to the fact that if the 1MB initial allocation area of the kernel is not 1MB-aligned, it is ought to be mapped from the middle of one MB to next, which requires 2 pmds. modified: .gdbinit modified: README new file: buildall.sh modified: include/l4/arch/arm/types.h modified: include/l4/generic/scheduler.h modified: loader/kernel.S modified: loader/main.c modified: loader/mylink.lds modified: loader/start.axf.S modified: src/glue/arm/init.c modified: src/glue/arm/memory.c modified: tasks/fs0/src/bdev.c modified: tasks/mm0/include/kdata.h modified: tasks/mm0/include/vm_area.h modified: tasks/mm0/src/init.c modified: tasks/mm0/src/task.c modified: tools/ksym_to_lds.py modified: tools/l4-qemu
This commit is contained in:
2
.gdbinit
2
.gdbinit
@@ -2,7 +2,7 @@ target remote localhost:1234
|
||||
load final.axf
|
||||
stepi
|
||||
sym final.axf
|
||||
break bkpt_phys_to_virt
|
||||
break break_virtual
|
||||
continue
|
||||
stepi
|
||||
sym start.axf
|
||||
|
||||
2
README
2
README
@@ -37,7 +37,7 @@ Codezero microkernel: Based on L4 microkernel principles, there are only a few
|
||||
system calls and the microkernel provides purely mechanism; threads and address
|
||||
spaces, and the methods of inter-process communication between them. Anything
|
||||
beyond these are policy and they are implemented in the userspace. Due to this
|
||||
rigorously simple design the microkernel can be used to design completely
|
||||
rigorously simple design the same microkernel can be used to design completely
|
||||
different operating systems. In terms of other features, the microkernel is
|
||||
preemptive, and smp-ready. Currently only synchronous communication is
|
||||
implemented, but this will change in the near future.
|
||||
|
||||
28
buildall.sh
Executable file
28
buildall.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -rf build
|
||||
echo -e "\n--- Building kernel --- "
|
||||
scons configure
|
||||
scons build
|
||||
cd tasks
|
||||
echo -e "\n--- Building libraries --- "
|
||||
cd libmem
|
||||
scons
|
||||
cd ../libl4
|
||||
scons
|
||||
cd ../libposix
|
||||
scons
|
||||
echo -e "\n--- Building tasks --- "
|
||||
cd ../mm0
|
||||
scons
|
||||
cd ../fs0
|
||||
scons
|
||||
cd ../test0
|
||||
scons
|
||||
echo -e "\n--- Building bootdesc ---"
|
||||
cd ../bootdesc
|
||||
scons
|
||||
cd ../..
|
||||
echo -e "\n--- Packing all up ---"
|
||||
./packer.sh
|
||||
echo -e "\n--- Build Completed ---\n"
|
||||
@@ -12,7 +12,7 @@ typedef signed short s16;
|
||||
typedef signed char s8;
|
||||
|
||||
/* Thread/Space id type */
|
||||
typedef unsigned int l4id_t;
|
||||
typedef int l4id_t;
|
||||
|
||||
#endif /* !__ASSEMBLY__ */
|
||||
#endif /* !__ARCH_TYPES_H__ */
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include INC_SUBARCH(mm.h)
|
||||
#include INC_GLUE(memory.h)
|
||||
|
||||
/* Ticks per second */
|
||||
#define HZ 1000
|
||||
#define TASK_TIMESLICE_DEFAULT 1
|
||||
/* Ticks per second, try ticks = 1000 + timeslice = 1 for regressed preemption test. */
|
||||
#define HZ 100
|
||||
#define TASK_TIMESLICE_DEFAULT 20
|
||||
/* #define TASK_TIMESLICE_DEFAULT (HZ/100)*/
|
||||
|
||||
static inline struct ktcb *current_task(void)
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
.section .kernel
|
||||
|
||||
.incbin "start.axf"
|
||||
.align 4
|
||||
.section .mm0
|
||||
|
||||
.incbin "mm0.axf"
|
||||
.align 4
|
||||
.section .bootdesc
|
||||
|
||||
.incbin "bootdesc.axf"
|
||||
|
||||
.align 4
|
||||
.section .mm0
|
||||
.incbin "mm0.axf"
|
||||
|
||||
.align 4
|
||||
.section .fs0
|
||||
|
||||
.incbin "fs0.axf"
|
||||
.align 4
|
||||
|
||||
.align 4
|
||||
.section .test0
|
||||
|
||||
.incbin "test0.axf"
|
||||
|
||||
.align 4
|
||||
|
||||
@@ -106,7 +106,6 @@ extern char _start_test0[];
|
||||
extern char _end_test0[];
|
||||
extern char _start_bootdesc[];
|
||||
extern char _end_bootdesc[];
|
||||
|
||||
/* This is a kernel symbol exported to loader's linker script from kernel build */
|
||||
extern char bkpt_phys_to_virt[];
|
||||
|
||||
@@ -127,17 +126,22 @@ main(void)
|
||||
arch_init();
|
||||
|
||||
printf("elf-loader:\tStarted\n");
|
||||
|
||||
printf("Loading the kernel...\n");
|
||||
load_image(&kernel_entry, _start_kernel, _end_kernel);
|
||||
printf("Loading the inittask\n");
|
||||
load_image(&mm0_entry, _start_mm0, _end_mm0);
|
||||
printf("Loading the roottask\n");
|
||||
load_image(&fs0_entry, _start_fs0, _end_fs0);
|
||||
printf("Loading the testtask\n");
|
||||
load_image(&test0_entry, _start_test0, _end_test0);
|
||||
|
||||
printf("Loading the bootdesc\n");
|
||||
load_image(&bootdesc_entry, _start_bootdesc, _end_bootdesc);
|
||||
|
||||
printf("Loading mm0\n");
|
||||
load_image(&mm0_entry, _start_mm0, _end_mm0);
|
||||
|
||||
printf("Loading fs0\n");
|
||||
load_image(&fs0_entry, _start_fs0, _end_fs0);
|
||||
|
||||
printf("Loading test0\n");
|
||||
load_image(&test0_entry, _start_test0, _end_test0);
|
||||
|
||||
printf("elf-loader:\tkernel entry point is %p\n", kernel_entry);
|
||||
arch_start_kernel(kernel_entry);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x8000;
|
||||
. = 0x2000000;
|
||||
.text : { *(.text) }
|
||||
.rodata : { *(.rodata) }
|
||||
.rodata1 : { *(.rodata1) }
|
||||
@@ -16,6 +16,9 @@ SECTIONS
|
||||
_start_kernel = .;
|
||||
*(.kernel)
|
||||
_end_kernel = .;
|
||||
_start_bootdesc = .;
|
||||
*(.bootdesc)
|
||||
_end_bootdesc = .;
|
||||
_start_mm0 = .;
|
||||
*(.mm0)
|
||||
_end_mm0 = .;
|
||||
@@ -25,9 +28,6 @@ SECTIONS
|
||||
_start_test0 = .;
|
||||
*(.test0)
|
||||
_end_test0 = .;
|
||||
_start_bootdesc = .;
|
||||
*(.bootdesc)
|
||||
_end_bootdesc = .;
|
||||
*(.data)
|
||||
}
|
||||
.got : { *(.got) *(.got.plt) }
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
.section .text
|
||||
.align 4
|
||||
.global bkpt_phys_to_virt;
|
||||
.type bkpt_phys_to_virt, function;
|
||||
.equ bkpt_phys_to_virt, 0x106f88
|
||||
.global break_virtual;
|
||||
.type break_virtual, function;
|
||||
.equ break_virtual, 0x106f9c
|
||||
|
||||
|
||||
@@ -133,8 +133,8 @@ void start_vm()
|
||||
"add r0, pc, %0 \n"
|
||||
/* Special symbol that is extracted and included in the loader.
|
||||
* Debuggers can break on it to load the virtual symbol table */
|
||||
".global bkpt_phys_to_virt;\n"
|
||||
"bkpt_phys_to_virt:\n"
|
||||
".global break_virtual;\n"
|
||||
"break_virtual:\n"
|
||||
"mov pc, r0 \n" /* (r0 has next instruction) */
|
||||
:
|
||||
: "r" (KERNEL_OFFSET)
|
||||
|
||||
@@ -39,8 +39,8 @@ unsigned int space_flags_to_ptflags(unsigned int flags)
|
||||
BUG(); return 0;
|
||||
}
|
||||
|
||||
#define NUM_PMD_TABLES 6
|
||||
#define NUM_PGD_TABLES 8
|
||||
#define NUM_PMD_TABLES 7
|
||||
//#define NUM_PGD_TABLES 8
|
||||
|
||||
/* Initial first level page table to provide startup mappings */
|
||||
SECTION(".kspace.pgd") pgd_table_t kspace;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
extern char _start_bdev[];
|
||||
extern char _end_bdev[];
|
||||
|
||||
__attribute__((section(".data.memfs"))) char blockdevice[SZ_16MB];
|
||||
__attribute__((section(".data.memfs"))) char blockdevice[SZ_1MB*2];
|
||||
|
||||
void *vfs_rootdev_open(void)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
struct initdata {
|
||||
struct bootdesc *bootdesc;
|
||||
struct vm_file *memfile;
|
||||
struct list_head boot_file_list;
|
||||
struct page_bitmap page_map;
|
||||
};
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ struct inode {
|
||||
struct vm_file {
|
||||
struct inode inode;
|
||||
unsigned long length;
|
||||
|
||||
struct list_head list; /* List of all vm files in memory */
|
||||
/* This is the cache of physical pages that this file has in memory. */
|
||||
struct list_head page_cache_list;
|
||||
struct vm_pager *pager;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <kdata.h>
|
||||
#include <memory.h>
|
||||
#include <mm/alloc_page.h>
|
||||
@@ -52,27 +53,28 @@ void init_mm(struct initdata *initdata)
|
||||
/* Create temporary run-time files in memory to test with mmap */
|
||||
void init_boot_files(struct initdata *initdata)
|
||||
{
|
||||
struct bootdesc *bd = initdata->bootdesc;
|
||||
int total_files = bd->total_images;
|
||||
struct vm_file *memfile;
|
||||
struct vm_file *f;
|
||||
struct svc_image *img;
|
||||
struct bootdesc *bd = initdata->bootdesc;
|
||||
|
||||
memfile = kzalloc(sizeof(struct vm_file) * total_files);
|
||||
initdata->memfile = memfile;
|
||||
BUG();
|
||||
for (int i = BOOTDESC_IMAGE_START; i < total_files; i++) {
|
||||
INIT_LIST_HEAD(&initdata->boot_file_list);
|
||||
for (int i = BOOTDESC_IMAGE_START; i < bd->total_images; i++) {
|
||||
img = &bd->images[i];
|
||||
if (!(!strcmp(img->name, "fs0") || !strcmp(img->name, "test0")))
|
||||
continue; /* Img is not what we want */
|
||||
|
||||
f = kzalloc(sizeof(*f));
|
||||
INIT_LIST_HEAD(&f->list);
|
||||
INIT_LIST_HEAD(&f->page_cache_list);
|
||||
list_add(&f->list, &initdata->boot_file_list);
|
||||
|
||||
/*
|
||||
* I have left the i_addr as physical on purpose. The inode is
|
||||
* not a readily usable memory address, its simply a unique key
|
||||
* that represents that file. Here, we use the physical address
|
||||
* of the memory file as that key. The pager must take action in
|
||||
* order to make use of it.
|
||||
* For boot files, we use the physical address of the memory
|
||||
* file as its inode.
|
||||
*/
|
||||
memfile[i].inode.i_addr = img->phys_start;
|
||||
memfile[i].length = img->phys_end - img->phys_start;
|
||||
memfile[i].pager = &default_file_pager;
|
||||
INIT_LIST_HEAD(&memfile[i].page_cache_list);
|
||||
f->inode.i_addr = img->phys_start;
|
||||
f->length = img->phys_end - img->phys_start;
|
||||
f->pager = &default_file_pager;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,38 +52,34 @@ void dump_tasks(void)
|
||||
#endif
|
||||
|
||||
|
||||
void create_init_tcbs(struct initdata *initdata)
|
||||
struct tcb *create_init_tcb(struct tcb_head *tcbs)
|
||||
{
|
||||
struct bootdesc *bd = initdata->bootdesc;
|
||||
INIT_LIST_HEAD(&tcb_head.list);
|
||||
tcb_head.total++;
|
||||
struct tcb *task = kzalloc(sizeof(struct tcb));
|
||||
|
||||
for (int i = BOOTDESC_IMAGE_START; i < bd->total_images; i++) {
|
||||
struct tcb *task = kzalloc(sizeof(struct tcb));
|
||||
/* Ids will be acquired from the kernel */
|
||||
task->tid = TASK_ID_INVALID;
|
||||
task->spid = TASK_ID_INVALID;
|
||||
task->swap_file = kzalloc(sizeof(struct vm_file));
|
||||
task->swap_file->pager = &swap_pager;
|
||||
vaddr_pool_init(task->swap_file_offset_pool, 0,
|
||||
__pfn(TASK_SWAPFILE_MAXSIZE));
|
||||
INIT_LIST_HEAD(&task->swap_file->page_cache_list);
|
||||
INIT_LIST_HEAD(&task->list);
|
||||
INIT_LIST_HEAD(&task->vm_area_list);
|
||||
list_add_tail(&task->list, &tcbs->list);
|
||||
tcbs->total++;
|
||||
|
||||
/* Ids will be acquired from the kernel */
|
||||
task->tid = TASK_ID_INVALID;
|
||||
task->spid = TASK_ID_INVALID;
|
||||
task->swap_file = kzalloc(sizeof(struct vm_file));
|
||||
task->swap_file->pager = &swap_pager;
|
||||
vaddr_pool_init(task->swap_file_offset_pool, 0,
|
||||
__pfn(TASK_SWAPFILE_MAXSIZE));
|
||||
INIT_LIST_HEAD(&task->swap_file->page_cache_list);
|
||||
INIT_LIST_HEAD(&task->list);
|
||||
INIT_LIST_HEAD(&task->vm_area_list);
|
||||
list_add_tail(&task->list, &tcb_head.list);
|
||||
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
int start_init_tasks(struct initdata *initdata)
|
||||
int start_boot_tasks(struct initdata *initdata, struct tcb_head *tcbs)
|
||||
{
|
||||
struct tcb *task;
|
||||
struct vm_file *file;
|
||||
int err;
|
||||
int i = BOOTDESC_IMAGE_START;
|
||||
|
||||
list_for_each_entry(task, &tcb_head.list, list) {
|
||||
struct vm_file *file = &initdata->memfile[i++];
|
||||
INIT_LIST_HEAD(&tcb_head.list);
|
||||
list_for_each_entry(file, &initdata->boot_file_list, list) {
|
||||
struct tcb *task = create_init_tcb(tcbs);
|
||||
unsigned int sp = align(USER_AREA_END - 1, 8);
|
||||
unsigned int pc = USER_AREA_START;
|
||||
struct task_ids ids = { .tid = task->tid, .spid = task->spid };
|
||||
@@ -132,7 +128,7 @@ int start_init_tasks(struct initdata *initdata)
|
||||
|
||||
/* Start the thread */
|
||||
if ((err = l4_thread_control(THREAD_RUN, &ids) < 0)) {
|
||||
printf("l4_thread_control failed with %d\n");
|
||||
printf("l4_thread_control failed with %d\n", err);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@@ -144,10 +140,14 @@ error:
|
||||
|
||||
void init_pm(struct initdata *initdata)
|
||||
{
|
||||
create_init_tcbs(initdata);
|
||||
start_init_tasks(initdata);
|
||||
start_boot_tasks(initdata, &tcb_head);
|
||||
}
|
||||
|
||||
/*
|
||||
* During its initialisation FS0 wants to learn how many boot tasks
|
||||
* are running, and their tids, which includes itself. This function
|
||||
* provides that information.
|
||||
*/
|
||||
void send_task_data(l4id_t requester)
|
||||
{
|
||||
struct tcb *t;
|
||||
|
||||
@@ -5,7 +5,7 @@ from string import atoi
|
||||
from os import popen2
|
||||
from os.path import join
|
||||
|
||||
symbols = ['bkpt_phys_to_virt']
|
||||
symbols = ['break_virtual']
|
||||
builddir = "build"
|
||||
loaderdir = "loader"
|
||||
image = "start.axf"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
cd build
|
||||
#arm-none-eabi-insight &
|
||||
qemu-system-arm -S -kernel final.axf -nographic -s -M versatilepb &
|
||||
sleep 0.5
|
||||
#/opt/bin/qemu-system-arm -s -kernel final.axf -nographic -m 128 -M versatilepb &
|
||||
qemu-system-arm -s -kernel final.axf -nographic -m 128 -M versatilepb &
|
||||
arm-none-eabi-insight ; pkill qemu-system-arm
|
||||
#arm-none-eabi-gdb ; pkill qemu-system-arm
|
||||
cd ..
|
||||
|
||||
Reference in New Issue
Block a user