iso_inspect/
unused/
-**.o
\ No newline at end of file
+**.o
+**.d
\ No newline at end of file
--- /dev/null
+Lunaix kernel arch specific ABI
+======
+
+This document provides a checklist if one wants to add support for novel architecture
+
+(It is far from complete, as the refactoring is going on)
+
+Implementation checklist:
+ [ ] An entry point that recieve control from second stage bootloader.
+ [ ] Interrupt vectoring must be done before invoking kernel_bootstrap.
+ [ ] Prepare the boot_handoff state struct, according to system info provided
+ by upstream bootloader
+ [ ] Invoke the kernel_bootstrap, pass the boot_handoff as it's only argument
+ This will transfer the control to Lunaix kernel.
+ [ ] A syscall handler, syscall table, and the syscall vectoring
+ [ ] A interrupt handler, must take care of context save/restore, signal handling
+ [ ] A system virtual memory map
+ [ ] Implement the following abstractions
+
+Referenced headers
+ * <some_arch>/includes/sys/abi.h
+ * <some_arch>/includes/sys/interrupt.h
+ * <some_arch>/includes/sys/port_io.h
+ * <some_arch>/includes/sys/pci_hba.h
+ * <some_arch>/includes/mm/mempart.h
+ * <some_arch>/includes/cpu.h
+
+Referenced functions
+ * includes/hal/hwtimer.h:hwtimer_choose
+ * includes/hal/hwrtc.h:hwrtc_choose
+ * includes/hal/intc.h:intc_init
+ * includes/lunaix/process.h:proc_init_transfer
\ No newline at end of file
#ifndef __LUNAIX_FLAGS_H
#define __LUNAIX_FLAGS_H
-#ifdef __ARCH_IA32
+#if __ARCH__ == i386
#define PLATFORM_TARGET "x86_32"
#else
#define PLATFORM_TARGET "unknown"
#define LUNAIX_VER "0.0.1-dev"
-/*
- Uncomment below to force LunaixOS use kernel page table when context switch
- to kernel space NOTE: This will make the kernel global.
-*/
-// #define USE_KERNEL_PG
-
/*
Uncomment below to disable all assertion
*/
#include <hal/hwtimer.h>
#include <lunaix/spike.h>
-struct hwtimer_context* sys_hwtctx;
+struct hwtimer_context* current_timer;
void
hwtimer_init(u32_t hertz, void* tick_callback)
hwt_ctx->init(hwt_ctx, hertz, tick_callback);
hwt_ctx->running_freq = hertz;
- sys_hwtctx = hwt_ctx;
+ current_timer = hwt_ctx;
}
ticks_t
hwtimer_base_frequency()
{
- return sys_hwtctx->base_freq;
+ return current_timer->base_freq;
}
ticks_t
hwtimer_current_systicks()
{
- return sys_hwtctx->systicks();
+ return current_timer->systicks();
}
ticks_t
{
// in case system frequency is less than 1000Hz
if (unit != TIME_MS) {
- return sys_hwtctx->running_freq * unit * value;
+ return current_timer->running_freq * unit * value;
}
- ticks_t freq_ms = sys_hwtctx->running_freq / 1000;
+ ticks_t freq_ms = current_timer->running_freq / 1000;
return freq_ms * value;
}
\ No newline at end of file
ticks_t running_freq;
};
+extern struct hwtimer_context* current_timer;
+
void
hwtimer_init(u32_t hertz, void* tick_callback);
// enable interrupt upon transfer
#define TRANSFER_IE 1
+/**
+ * @brief Setup process initial context, used to initiate first switch
+ *
+ * @param proc
+ * @param stop
+ * @param target
+ * @param flags
+ */
void
proc_init_transfer(struct proc_info* proc, ptr_t stop, ptr_t target, int flags);
ksrc_files := $(foreach f, $(ksrc_dirs), $(shell find $(f) -name "*.[cS]"))
ksrc_objs := $(addsuffix .o,$(ksrc_files))
+ksrc_deps := $(addsuffix .d,$(ksrc_files))
kinc_opts := $(addprefix -I,$(kinc_dirs))
$(call status_,CC,$<)
@$(CC) $(CFLAGS) $(kinc_opts) -c $< -o $@
-$(kbin): $(ksrc_objs) $(kbin_dir)
+$(kbin): $(kbin_dir) $(ksrc_files) $(ksrc_objs)
$(call status_,LD,$@)
@$(CC) -T link/linker.ld -o $(kbin) $(ksrc_objs) $(LDFLAGS)
all: $(kbin) $(kbin_dir)/modksyms
clean:
- @rm -f $(ksrc_objs)
\ No newline at end of file
+ @rm -f $(ksrc_objs)
+ @rm -f $(ksrc_deps)
\ No newline at end of file
#include <sdbg/protocol.h>
-#include <hal/acpi/acpi.h>
-#include <hal/ahci/ahci.h>
#include <hal/pci.h>
#include <klibc/string.h>
__proc0()
{
/*
- * We must defer boot code/data cleaning after we successfully escape that
- * area
+ * We must defer boot code/data cleaning to here, after we successfully
+ * escape that area
*/
boot_cleanup();
twifs_register_plugins();
- /* we must start probing pci after all drivers are registered! */
+ /*
+ * all device registering and loading must defered to here!
+ * due to limited stack size and partial scheduling context
+ */
pci_load_devices();
// debugger
serial_init();
sdbg_init();
- // FIXME ps2 kbd is x86 PC specific, not here.
- // peripherals & chipset features
+ // FIXME ps2 kbd is a device, must not be here
ps2_kbd_init();
// console
}
struct proc_info* root_proc = sched_ctx._procs[0];
- __current->sleep.wakeup_time = clock_systime() + seconds * 1000;
+ __current->sleep.wakeup_time = clock_systime() + seconds;
if (llist_empty(&__current->sleep.sleepers)) {
llist_append(&root_proc->sleep.sleepers, &__current->sleep.sleepers);
return 0;
}
-// FIXME issue with alarm, paused parent process never got wake up, check what
-// has been fucked up by refactoring.
-
__DEFINE_LXSYSCALL1(unsigned int, alarm, unsigned int, seconds)
{
time_t prev_ddl = __current->sleep.alarm_time;
time_t now = clock_systime();
- __current->sleep.alarm_time = seconds ? now + seconds * 1000 : 0;
+ __current->sleep.alarm_time = seconds ? now + seconds : 0;
struct proc_info* root_proc = sched_ctx._procs[0];
if (llist_empty(&__current->sleep.sleepers)) {
clock_systime()
{
ticks_t t = hwtimer_current_systicks();
- return t / hwtimer_base_frequency();
+ return t / current_timer->running_freq;
}
void
include $(mkinc_dir)/qemu.mkinc
include $(mkinc_dir)/utils.mkinc
-
ARCH ?= i386
export ARCH
-fno-inline-small-functions \
-fno-indirect-inlining
-CFLAGS := -std=gnu99 -ffreestanding $(OFLAGS) $(W) $(ARCH_OPT)
+CFLAGS := -std=gnu99 -ffreestanding -MMD $(OFLAGS) $(W) $(ARCH_OPT)
ifeq ($(BUILD_MODE),debug)
O = -Og