mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
add single kernel support
HermitCore apps are directly bootable with the new loader
This commit is contained in:
parent
85d6ccd8eb
commit
f75dbe82b3
5 changed files with 76 additions and 29 deletions
|
@ -165,6 +165,8 @@ struct state {
|
|||
uint64_t ss;
|
||||
};
|
||||
|
||||
const int32_t is_single_kernel(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -63,6 +63,8 @@ static const apic_processor_entry_t* apic_processors[MAX_APIC_CORES] = {[0 ... M
|
|||
extern int32_t boot_processor;
|
||||
extern uint32_t cpu_freq;
|
||||
extern atomic_int32_t cpu_online;
|
||||
extern int32_t isle;
|
||||
extern int32_t possible_isles;
|
||||
apic_mp_t* apic_mp __attribute__ ((section (".data"))) = NULL;
|
||||
static apic_config_table_t* apic_config = NULL;
|
||||
static size_t lapic = 0;
|
||||
|
@ -494,6 +496,11 @@ found_mp:
|
|||
if (!apic_mp)
|
||||
goto no_mp;
|
||||
|
||||
if (isle < 0) {
|
||||
//TODO: add detection of NUMA node
|
||||
isle = 0;
|
||||
}
|
||||
|
||||
kprintf("Found MP config table at 0x%x\n", apic_mp->mp_config);
|
||||
kprintf("System uses Multiprocessing Specification 1.%u\n", apic_mp->version);
|
||||
kprintf("MP features 1: %u\n", apic_mp->features[0]);
|
||||
|
|
|
@ -49,6 +49,10 @@ DEFINE_PER_CORE(uint64_t, last_rdtsc, 0);
|
|||
|
||||
void check_ticks(void)
|
||||
{
|
||||
// do we already know the cpu frequency? => if not, ignore this check
|
||||
if (!cpu_freq)
|
||||
return;
|
||||
|
||||
if (has_rdtscp()){
|
||||
uint64_t curr_rdtsc = rdtscp(NULL);
|
||||
uint64_t diff;
|
||||
|
@ -89,6 +93,10 @@ static void timer_handler(struct state *s)
|
|||
#ifndef DYNAMIC_TICKS
|
||||
/* Increment our 'tick counter' */
|
||||
set_per_core(timer_ticks, per_core(timer_ticks)+1);
|
||||
#else
|
||||
// do we already know the cpu frequency? => if not, use timer interrupt to count the ticks
|
||||
if (!cpu_freq)
|
||||
set_per_core(timer_ticks, per_core(timer_ticks)+1);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
@ -165,6 +173,7 @@ static int pit_init(void)
|
|||
|
||||
outportb(0x40, LATCH(TIMER_FREQ) >> 8); /* high byte */
|
||||
|
||||
kputs("pit_init\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -148,10 +148,6 @@ static void tcpip_init_done(void* arg)
|
|||
|
||||
static int init_netifs(void)
|
||||
{
|
||||
struct ip_addr ipaddr;
|
||||
struct ip_addr netmask;
|
||||
struct ip_addr gw;
|
||||
err_t err;
|
||||
sys_sem_t sem;
|
||||
|
||||
if(sys_sem_new(&sem, 0) != ERR_OK)
|
||||
|
@ -162,36 +158,44 @@ static int init_netifs(void)
|
|||
kprintf("TCP/IP initialized.\n");
|
||||
sys_sem_free(&sem);
|
||||
|
||||
/* Set network address variables */
|
||||
IP4_ADDR(&gw, 192,168,28,1);
|
||||
IP4_ADDR(&ipaddr, 192,168,28,isle+2);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
if (!is_single_kernel())
|
||||
{
|
||||
struct ip_addr ipaddr;
|
||||
struct ip_addr netmask;
|
||||
struct ip_addr gw;
|
||||
err_t err;
|
||||
|
||||
/* register our Memory Mapped Virtual IP interface in the lwip stack
|
||||
* and tell him how to use the interface:
|
||||
* - mmnif_dev : the device data storage
|
||||
* - ipaddr : the ip address wich should be used
|
||||
* - gw : the gateway wicht should be used
|
||||
* - mmnif_init : the initialization which has to be done in order to use our interface
|
||||
* - ip_input : tells him that he should use ip_input
|
||||
*/
|
||||
/* Set network address variables */
|
||||
IP4_ADDR(&gw, 192,168,28,1);
|
||||
IP4_ADDR(&ipaddr, 192,168,28,isle+2);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
|
||||
/* register our Memory Mapped Virtual IP interface in the lwip stack
|
||||
* and tell him how to use the interface:
|
||||
* - mmnif_dev : the device data storage
|
||||
* - ipaddr : the ip address wich should be used
|
||||
* - gw : the gateway wicht should be used
|
||||
* - mmnif_init : the initialization which has to be done in order to use our interface
|
||||
* - ip_input : tells him that he should use ip_input
|
||||
*/
|
||||
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
||||
if ((err = netifapi_netif_add(&mmnif_netif, &ipaddr, &netmask, &gw, NULL, mmnif_init, tcpip_input)) != ERR_OK)
|
||||
if ((err = netifapi_netif_add(&mmnif_netif, &ipaddr, &netmask, &gw, NULL, mmnif_init, tcpip_input)) != ERR_OK)
|
||||
#else
|
||||
/*
|
||||
* Note: Our drivers guarantee that the input function will be called in the context of the tcpip thread.
|
||||
* => Therefore, we are able to use ip_input instead of tcpip_input
|
||||
*/
|
||||
if ((err = netifapi_netif_add(&mmnif_netif, &ipaddr, &netmask, &gw, NULL, mmnif_init, ip_input)) != ERR_OK)
|
||||
/*
|
||||
* Note: Our drivers guarantee that the input function will be called in the context of the tcpip thread.
|
||||
* => Therefore, we are able to use ip_input instead of tcpip_input
|
||||
*/
|
||||
if ((err = netifapi_netif_add(&mmnif_netif, &ipaddr, &netmask, &gw, NULL, mmnif_init, ip_input)) != ERR_OK)
|
||||
#endif
|
||||
{
|
||||
kprintf("Unable to add the intra network interface: err = %d\n", err);
|
||||
return -ENODEV;
|
||||
}
|
||||
{
|
||||
kprintf("Unable to add the intra network interface: err = %d\n", err);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* tell lwip all initialization is done and we want to set it up */
|
||||
netifapi_netif_set_default(&mmnif_netif);
|
||||
netifapi_netif_set_up(&mmnif_netif);
|
||||
/* tell lwip all initialization is done and we want to set it up */
|
||||
netifapi_netif_set_default(&mmnif_netif);
|
||||
netifapi_netif_set_up(&mmnif_netif);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -337,6 +341,14 @@ static int initd(void* arg)
|
|||
// initialize network
|
||||
init_netifs();
|
||||
|
||||
if (is_single_kernel()) {
|
||||
char* dummy[] = {"app_name", NULL};
|
||||
|
||||
libc_start(1, dummy, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// initialize iRCCE
|
||||
init_rcce();
|
||||
|
||||
|
|
|
@ -32,8 +32,10 @@
|
|||
#include <hermit/spinlock.h>
|
||||
#include <asm/atomic.h>
|
||||
#include <asm/processor.h>
|
||||
#include <asm/vga.h>
|
||||
|
||||
static atomic_int32_t kmsg_counter = ATOMIC_INIT(-1);
|
||||
static spinlock_irqsave_t vga_lock = SPINLOCK_IRQSAVE_INIT;
|
||||
|
||||
/* Workaround for a compiler bug. gcc 5.1 seems to ignore this array, if we
|
||||
defined it as as static array. At least it is as static array not part of
|
||||
|
@ -42,6 +44,9 @@ static atomic_int32_t kmsg_counter = ATOMIC_INIT(-1);
|
|||
|
||||
int koutput_init(void)
|
||||
{
|
||||
if (is_single_kernel())
|
||||
vga_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -56,6 +61,12 @@ int kputchar(int c)
|
|||
pos = atomic_int32_inc(&kmsg_counter);
|
||||
kmessages[pos % KMSG_SIZE] = (unsigned char) c;
|
||||
|
||||
if (is_single_kernel()) {
|
||||
spinlock_irqsave_lock(&vga_lock);
|
||||
vga_putchar(c);
|
||||
spinlock_irqsave_unlock(&vga_lock);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -68,5 +79,11 @@ int kputs(const char *str)
|
|||
kmessages[pos % KMSG_SIZE] = str[i];
|
||||
}
|
||||
|
||||
if (is_single_kernel()) {
|
||||
spinlock_irqsave_lock(&vga_lock);
|
||||
vga_puts(str);
|
||||
spinlock_irqsave_unlock(&vga_lock);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue