aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'extras/mini-os/kernel.c')
-rw-r--r--extras/mini-os/kernel.c101
1 files changed, 29 insertions, 72 deletions
diff --git a/extras/mini-os/kernel.c b/extras/mini-os/kernel.c
index d66dd35ab0..0799116aa6 100644
--- a/extras/mini-os/kernel.c
+++ b/extras/mini-os/kernel.c
@@ -6,6 +6,7 @@
*
* Copyright (c) 2002-2003, K A Fraser & R Neugebauer
* Copyright (c) 2005, Grzegorz Milos, Intel Research Cambridge
+ * Copyright (c) 2006, Robert Kaiser, FH Wiesbaden
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@@ -39,49 +40,6 @@
#include <xen/features.h>
#include <xen/version.h>
-/*
- * Shared page for communicating with the hypervisor.
- * Events flags go here, for example.
- */
-shared_info_t *HYPERVISOR_shared_info;
-
-/*
- * This structure contains start-of-day info, such as pagetable base pointer,
- * address of the shared_info structure, and things like that.
- */
-union start_info_union start_info_union;
-
-/*
- * Just allocate the kernel stack here. SS:ESP is set up to point here
- * in head.S.
- */
-char stack[8192];
-
-
-/* Assembler interface fns in entry.S. */
-void hypervisor_callback(void);
-void failsafe_callback(void);
-
-extern char shared_info[PAGE_SIZE];
-
-#if !defined(CONFIG_X86_PAE)
-#define __pte(x) ((pte_t) { (x) } )
-#else
-#define __pte(x) ({ unsigned long long _x = (x); \
- ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })
-#endif
-
-static shared_info_t *map_shared_info(unsigned long pa)
-{
- if ( HYPERVISOR_update_va_mapping(
- (unsigned long)shared_info, __pte(pa | 7), UVMF_INVLPG) )
- {
- printk("Failed to map shared_info!!\n");
- do_exit();
- }
- return (shared_info_t *)shared_info;
-}
-
u8 xen_features[XENFEAT_NR_SUBMAPS * 32];
@@ -109,11 +67,24 @@ void xenbus_tester(void *p)
/* test_xenbus(); */
}
+void periodic_thread(void *p)
+{
+ struct timeval tv;
+ printk("Periodic thread started.\n");
+ for(;;)
+ {
+ gettimeofday(&tv);
+ printk("T(s=%ld us=%ld)\n", tv.tv_sec, tv.tv_usec);
+ sleep(1000);
+ }
+}
+
/* This should be overridden by the application we are linked against. */
__attribute__((weak)) int app_main(start_info_t *si)
{
printk("Dummy main: start_info=%p\n", si);
create_thread("xenbus_tester", xenbus_tester, si);
+ create_thread("periodic_thread", periodic_thread, si);
return 0;
}
@@ -126,32 +97,10 @@ void start_kernel(start_info_t *si)
(void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello);
- /* Copy the start_info struct to a globally-accessible area. */
- /* WARN: don't do printk before here, it uses information from
- shared_info. Use xprintk instead. */
- memcpy(&start_info, si, sizeof(*si));
-
- /* set up minimal memory infos */
- phys_to_machine_mapping = (unsigned long *)start_info.mfn_list;
-
- /* Grab the shared_info pointer and put it in a safe place. */
- HYPERVISOR_shared_info = map_shared_info(start_info.shared_info);
-
- /* Set up event and failsafe callback addresses. */
-#ifdef __i386__
- HYPERVISOR_set_callbacks(
- __KERNEL_CS, (unsigned long)hypervisor_callback,
- __KERNEL_CS, (unsigned long)failsafe_callback);
-#else
- HYPERVISOR_set_callbacks(
- (unsigned long)hypervisor_callback,
- (unsigned long)failsafe_callback, 0);
-#endif
+ arch_init(si);
+
trap_init();
- /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
- __sti();
-
/* print out some useful information */
printk("Xen Minimal OS!\n");
printk("start_info: %p\n", si);
@@ -163,16 +112,20 @@ void start_kernel(start_info_t *si)
printk(" flags: 0x%x\n", (unsigned int)si->flags);
printk(" cmd_line: %s\n",
si->cmd_line ? (const char *)si->cmd_line : "NULL");
- printk(" stack: %p-%p\n", stack, stack + 8192);
+
+ /* Set up events. */
+ init_events();
+
+ /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
+ __sti();
+
+ arch_print_info();
setup_xen_features();
/* Init memory management. */
init_mm();
- /* Set up events. */
- init_events();
-
/* Init time and timers. */
init_time();
@@ -206,5 +159,9 @@ void start_kernel(start_info_t *si)
void do_exit(void)
{
printk("Do_exit called!\n");
- for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
+ for( ;; )
+ {
+ struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
+ HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+ }
}