Merge branch 'master' into svm

This commit is contained in:
Stefan Lankes 2011-08-15 01:13:02 -07:00
commit 5c3c757cbb
84 changed files with 4357 additions and 1489 deletions

2
.gitignore vendored
View file

@ -15,6 +15,8 @@ newlib/examples/hello
newlib/examples/echo
newlib/examples/tests
newlib/examples/jacobi
newlib/examples/server
newlib/examples/client
newlib/tmp/*
newlib/x86/*
metalsvm.elf

View file

@ -42,9 +42,9 @@ extern "C" {
// feature list 1
#define CPU_FEATURE_FPU (1 << 0)
#define CPU_FEATURE_MMX (1 << 23)
#define CPU_FEATURE_FXSR (1 << 24)
#define CPU_FEATURE_FXSR (1 << 24)
#define CPU_FEATURE_SSE (1 << 25)
#define CPU_FEATURE_SSE2 (1 << 26)
#define CPU_FEATURE_SSE2 (1 << 26)
// feature list 2
#define CPU_FEATURE_AVX (1 << 28)

View file

@ -1,20 +1,36 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
* This file is part of MetalSVM.
*/
/**

View file

@ -36,6 +36,11 @@
extern "C" {
#endif
/**
* @brief Dump some scheduling statistics
*/
int dump_scheduling_statistics(void);
/** @brief Fork a task from current task
*
* @param task Pointer to the task structure to fork to

View file

@ -301,9 +301,6 @@ void smp_start(uint32_t id)
// install IDT
idt_install();
// enable additional cpu features
cpu_detection();
/* enable paging */
write_cr3((uint32_t)get_boot_pgd());
i = read_cr0();
@ -320,6 +317,9 @@ void smp_start(uint32_t id)
*/
register_task(per_core(current_task));
// enable additional cpu features
cpu_detection();
smp_main();
// idle loop
@ -327,15 +327,18 @@ void smp_start(uint32_t id)
}
#endif
#ifndef CONFIG_MULTIBOOT
#if 1
static apic_mp_t* search_apic(size_t base, size_t limit) {
size_t ptr;
apic_mp_t* tmp;
for (ptr=base; ptr<=limit-sizeof(uint32_t); ptr++) {
if (*((uint32_t*) ptr) == MP_FLT_SIGNATURE) {
if (!(((apic_mp_t*)ptr)->version > 4) && ((apic_mp_t*)ptr)->features[0])
return (apic_mp_t*) ptr;
}
tmp = (apic_mp_t*) ptr;
if (tmp->signature == MP_FLT_SIGNATURE) {
if (!((tmp->version > 4) || tmp->features[0]))
return tmp;
}
}
return NULL;
@ -561,7 +564,7 @@ static int apic_probe(void)
uint32_t i, count;
int isa_bus = -1;
#ifndef CONFIG_MULTIBOOT
#if 1
apic_mp = search_apic(0xF0000, 0x100000);
if (apic_mp)
goto found_mp;
@ -590,7 +593,7 @@ static int apic_probe(void)
for(i=0; (i<mmap->len-sizeof(uint32_t)) && (addr < 0x0FFFFF); i++, addr++) {
if (*((uint32_t*) addr) == MP_FLT_SIGNATURE) {
apic_mp = (apic_mp_t*) addr;
if (!(apic_mp->version > 4) && apic_mp->features[0])
if (!((apic_mp->version > 4) || apic_mp->features[0]))
goto found_mp;
}
}

View file

@ -116,9 +116,8 @@ int arch_fork(task_t* task)
asm volatile ("pop %0" : "=r"(task_state_segments[id].ecx));
asm volatile ("pop %0" : "=r"(task_state_segments[id].eax));
// store current EFLAGS and set IF flag
// => the parent task will enable the interrupt handling
asm volatile ("pushf; pop %%eax; or $2,%%ah" : "=a"(task_state_segments[id].eflags));
// store the current EFLAGS
asm volatile ("pushf; pop %%eax" : "=a"(task_state_segments[id].eflags));
// This will be the entry point for the new task.
asm volatile ("call read_eip" : "=a"(task_state_segments[id].eip));
@ -146,7 +145,7 @@ int create_default_frame(task_t* task, internal_entry_point_t ep, void* arg)
task_state_segments[id].fs = ds;
task_state_segments[id].gs = ds;
task_state_segments[id].es = ds;
task_state_segments[id].eflags = 0x1202;
task_state_segments[id].eflags = 0x1002; // 0x1202;
task_state_segments[id].cr3 = (uint32_t) (virt_to_phys((size_t)task->pgd));
task_state_segments[id].eip = (uint32_t) ep;
task_state_segments[id].esp = (uint32_t) kstacks[id] + KERNEL_STACK_SIZE - sizeof(size_t);

View file

@ -23,6 +23,7 @@
#include <metalsvm/time.h>
#include <metalsvm/processor.h>
#include <metalsvm/errno.h>
#include <metalsvm/spinlock.h>
#include <asm/irq.h>
#include <asm/irqflags.h>
#include <asm/gdt.h>
@ -33,7 +34,7 @@
* This will keep track of how many ticks the system
* has been running for
*/
static volatile uint64_t timer_ticks __attribute__ ((aligned (CACHE_LINE))) = 0;
static volatile uint64_t timer_ticks = 0;
uint64_t get_clock_tick(void)
{
@ -60,40 +61,60 @@ int sys_times(struct tms* buffer, clock_t* clock)
*/
static void timer_handler(struct state *s)
{
uint32_t i;
/* Increment our 'tick counter' */
#if MAX_CORES > 1
if (smp_id() == 0)
timer_ticks++;
#else
timer_ticks++;
#endif
{
timer_ticks++;
/*
* Every TIMER_FREQ clocks (approximately 1 second), we will
* display a message on the screen
*/
/*if (timer_ticks % TIMER_FREQ == 0) {
vga_puts("One second has passed\n");
}*/
/*
* Every TIMER_FREQ clocks (approximately 1 second), we will
* display a message on the screen
*/
/*if (timer_ticks % TIMER_FREQ == 0) {
vga_puts("One second has passed\n");
}*/
}
}
/*
* This will continuously loop until the given time has
* been reached
*/
void timer_wait(unsigned int ticks)
int timer_wait(unsigned int ticks)
{
uint64_t eticks = timer_ticks + ticks;
task_t* curr_task = per_core(current_task);
while (timer_ticks < eticks) {
if (curr_task->status == TASK_IDLE)
{
/*
* This will continuously loop until the given time has
* been reached
*/
while (timer_ticks < eticks) {
check_workqueues();
// recheck break condition
if (timer_ticks >= eticks)
break;
HALT;
}
} else if (timer_ticks < eticks) {
check_workqueues();
// recheck break condition
if (timer_ticks >= eticks)
break;
if (timer_ticks < eticks) {
uint32_t flags = irq_nested_disable();
curr_task->timeout = eticks;
curr_task->flags |= TASK_TIMER_USED;
curr_task->status = TASK_BLOCKED;
irq_nested_enable(flags);
reschedule();
reschedule();
}
}
return 0;
}
#define LATCH(f) ((CLOCK_TICK_RATE + f/2) / f)

View file

@ -730,12 +730,6 @@ int arch_paging_init(void)
// map SCC's bootinfo
map_region(SCC_BOOTINFO, SCC_BOOTINFO, 1, MAP_KERNEL_SPACE);
// map the initial ramdisk
npages = bootinfo->size >> PAGE_SHIFT;
if (bootinfo->size & (PAGE_SIZE-1))
npages++;
map_region(bootinfo->addr, bootinfo->addr, npages, MAP_KERNEL_SPACE);
// map SCC's configuration registers
viraddr = map_region(CRB_X0_Y0, CRB_X0_Y0, (CRB_OWN-CRB_X0_Y0+16*1024*1024) >> PAGE_SHIFT, MAP_KERNEL_SPACE|MAP_NO_CACHE);
kprintf("Map configuration registers at 0x%x\n", viraddr);
@ -756,6 +750,15 @@ int arch_paging_init(void)
write_cr0(i);
paging_enabled = 1;
#ifdef CONFIG_ROCKCREEK
// map the initial ramdisk
npages = bootinfo->size >> PAGE_SHIFT;
if (bootinfo->size & (PAGE_SIZE-1))
npages++;
bootinfo->addr = map_region(0, bootinfo->addr, npages, MAP_KERNEL_SPACE);
kprintf("Map initrd at 0x%x (size %u bytes)\n", bootinfo->addr, bootinfo->size);
#endif
/*
* we turned on paging
* => now, we are able to register our task for Task State Switching

File diff suppressed because it is too large Load diff

View file

@ -276,7 +276,7 @@ static void rckemacif_input(struct netif* netif, struct pbuf* p)
#endif /* PPPOE_SUPPORT */
/* full packet send to tcpip_thread to process */
if (mynetif->input(p, mynetif) != ERR_OK) {
LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_input: IP input error\n"));
LWIP_DEBUGF(NETIF_DEBUG, ("rckemacif_input: IP input error\n"));
pbuf_free(p);
}
break;

View file

@ -113,7 +113,8 @@ static err_t rtl8139if_output(struct netif* netif, struct pbuf* p)
static void rtl8139if_input(struct netif* netif, struct pbuf* p)
{
struct eth_hdr *ethhdr;
err_t err;
/* points to packet payload, which starts with an Ethernet header */
ethhdr = p->payload;
@ -127,8 +128,9 @@ static void rtl8139if_input(struct netif* netif, struct pbuf* p)
case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
/* full packet send to tcpip_thread to process */
if (mynetif->input(p, mynetif) != ERR_OK) {
LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_input: IP input error\n"));
err = mynetif->input(p, mynetif);
if (err != ERR_OK) {
LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_input: IP input error %d\n", (int32_t) err));
pbuf_free(p);
}
break;

View file

@ -42,6 +42,9 @@ int network_init(void);
/** @brief Shutdown the networking subsystem. */
int network_shutdown(void);
/** @brief Entry point of the init task */
int initd(void* arg);
#ifdef __cplusplus
}
#endif

View file

@ -24,6 +24,7 @@
#include <metalsvm/mailbox_types.h>
#include <metalsvm/tasks.h>
#include <metalsvm/semaphore.h>
#include <metalsvm/errno.h>
#ifdef __cplusplus
extern "C" {
@ -32,7 +33,7 @@ extern "C" {
#define MAILBOX(name, type) \
inline static int mailbox_##name##_init(mailbox_##name##_t* m) { \
if (BUILTIN_EXPECT(!m, 0)) \
return -1; \
return -EINVAL; \
\
memset(m->buffer, 0x00, sizeof(type)*MAILBOX_SIZE); \
m->wpos = m->rpos = 0; \
@ -46,7 +47,7 @@ extern "C" {
\
inline static int mailbox_##name##_destroy(mailbox_##name##_t* m) { \
if (BUILTIN_EXPECT(!m, 0)) \
return -1; \
return -EINVAL; \
\
sem_destroy(&m->mails); \
sem_destroy(&m->boxes); \
@ -58,9 +59,9 @@ extern "C" {
\
inline static int mailbox_##name##_post(mailbox_##name##_t* m, type mail) { \
if (BUILTIN_EXPECT(!m, 0)) \
return -1; \
return -EINVAL; \
\
sem_wait(&m->boxes); \
sem_wait(&m->boxes, 0); \
spinlock_lock(&m->wlock); \
m->buffer[m->wpos] = mail; \
m->wpos = (m->wpos+1) % MAILBOX_SIZE; \
@ -70,11 +71,29 @@ extern "C" {
return 0; \
} \
\
inline static int mailbox_##name##_fetch(mailbox_##name##_t* m, type* mail) { \
if (BUILTIN_EXPECT(!m || !mail, 0)) \
return -1; \
inline static int mailbox_##name##_trypost(mailbox_##name##_t* m, type mail) { \
if (BUILTIN_EXPECT(!m, 0)) \
return -EINVAL; \
\
sem_wait(&m->mails); \
if (sem_trywait(&m->boxes)) \
return -EBUSY; \
spinlock_lock(&m->wlock); \
m->buffer[m->wpos] = mail; \
m->wpos = (m->wpos+1) % MAILBOX_SIZE; \
spinlock_unlock(&m->wlock); \
sem_post(&m->mails); \
\
return 0; \
} \
\
inline static int mailbox_##name##_fetch(mailbox_##name##_t* m, type* mail, uint32_t ms) { \
int err; \
\
if (BUILTIN_EXPECT(!m || !mail, 0)) \
return -EINVAL; \
\
err = sem_wait(&m->mails, ms); \
if (err) return err; \
spinlock_lock(&m->rlock); \
*mail = m->buffer[m->rpos]; \
m->rpos = (m->rpos+1) % MAILBOX_SIZE; \
@ -86,10 +105,10 @@ extern "C" {
\
inline static int mailbox_##name##_tryfetch(mailbox_##name##_t* m, type* mail) { \
if (BUILTIN_EXPECT(!m || !mail, 0)) \
return -1; \
return -EINVAL; \
\
if (sem_trywait(&m->mails) != 0) \
return -1; \
return -EINVAL; \
spinlock_lock(&m->rlock); \
*mail = m->buffer[m->rpos]; \
m->rpos = (m->rpos+1) % MAILBOX_SIZE; \

View file

@ -29,6 +29,8 @@
#include <metalsvm/string.h>
#include <metalsvm/semaphore_types.h>
#include <metalsvm/spinlock.h>
#include <metalsvm/errno.h>
#include <metalsvm/time.h>
#ifdef __cplusplus
extern "C" {
@ -43,19 +45,19 @@ extern "C" {
*
* @return
* - 0 on success
* - -1 on failure
* - -EINVAL on invalid argument
*/
inline static int sem_init(sem_t* s, unsigned int v) {
unsigned int i;
if (BUILTIN_EXPECT(!s, 0))
return -1;
return -EINVAL;
s->value = v;
s->pos = 0;
for(i=0; i<MAX_TASKS; i++)
s->queue[i] = MAX_TASKS;
spinlock_init(&s->lock);
spinlock_irqsave_init(&s->lock);
return 0;
}
@ -63,42 +65,13 @@ inline static int sem_init(sem_t* s, unsigned int v) {
/** @brief Destroy semaphore
* @return
* - 0 on success
* - -1 on failure
* - -EINVAL on invalid argument
*/
inline static int sem_destroy(sem_t* s) {
if (BUILTIN_EXPECT(!s, 0))
return -1;
return -EINVAL;
spinlock_destroy(&s->lock);
return 0;
}
/** @brief Blocking wait for semaphore
*
* This will put your task to sleep
*
* @return
* - 0 on success
* - -1 on failure
*/
inline static int sem_wait(sem_t* s) {
if (BUILTIN_EXPECT(!s, 0))
return -1;
next_try:
spinlock_lock(&s->lock);
if (s->value > 0) {
s->value--;
spinlock_unlock(&s->lock);
} else {
s->queue[s->pos] = per_core(current_task)->id;
s->pos = (s->pos + 1) % MAX_TASKS;
block_task(per_core(current_task)->id);
spinlock_unlock(&s->lock);
reschedule();
goto next_try;
}
spinlock_irqsave_destroy(&s->lock);
return 0;
}
@ -109,37 +82,111 @@ next_try:
*
* @return
* - 0 on success (You got the semaphore)
* - -1 on failure (You still have to wait)
* - -EINVAL on invalid argument
* - -ECANCELED on failure (You still have to wait)
*/
inline static int sem_trywait(sem_t* s) {
int ret = -1;
int ret = -ECANCELED;
if (BUILTIN_EXPECT(!s, 0))
return -1;
return -EINVAL;
spinlock_lock(&s->lock);
spinlock_irqsave_lock(&s->lock);
if (s->value > 0) {
s->value--;
ret = 0;
}
spinlock_unlock(&s->lock);
spinlock_irqsave_unlock(&s->lock);
return ret;
}
/** @brief Blocking wait for semaphore
*
* @param ms Timeout in milliseconds
* @return
* - 0 on success
* - -EINVAL on invalid argument
* - -ETIME on timer expired
*/
inline static int sem_wait(sem_t* s, uint32_t ms) {
task_t* curr_task = per_core(current_task);
if (BUILTIN_EXPECT(!s, 0))
return -EINVAL;
if (!ms) {
next_try1:
spinlock_irqsave_lock(&s->lock);
if (s->value > 0) {
s->value--;
spinlock_irqsave_unlock(&s->lock);
} else {
s->queue[s->pos] = curr_task->id;
s->pos = (s->pos + 1) % MAX_TASKS;
curr_task->status = TASK_BLOCKED;
spinlock_irqsave_unlock(&s->lock);
reschedule();
NOP2;
goto next_try1;
}
return 0;
} else {
uint32_t ticks = (ms * TIMER_FREQ) / 1000;
uint32_t remain = (ms * TIMER_FREQ) % 1000;
if (ticks) {
uint64_t deadline = get_clock_tick() + ticks;
next_try2:
spinlock_irqsave_lock(&s->lock);
if (s->value > 0) {
s->value--;
spinlock_irqsave_unlock(&s->lock);
return 0;
} else {
if (get_clock_tick() >= deadline) {
spinlock_irqsave_unlock(&s->lock);
goto timeout;
}
s->queue[s->pos] = curr_task->id;
s->pos = (s->pos + 1) % MAX_TASKS;
curr_task->timeout = deadline;
curr_task->flags |= TASK_TIMER_USED;
curr_task->status = TASK_BLOCKED;
spinlock_irqsave_unlock(&s->lock);
reschedule();
goto next_try2;
}
}
timeout:
while (remain) {
udelay(1000);
remain--;
if (!sem_trywait(s))
return 0;
}
return -ETIME;
}
}
/** @brief Give back resource
* @return
* - 0 on success
* - -1 on failure
* - -EINVAL on invalid argument
*/
inline static int sem_post(sem_t* s) {
if (BUILTIN_EXPECT(!s, 0))
return -1;
return -EINVAL;
spinlock_lock(&s->lock);
spinlock_irqsave_lock(&s->lock);
if (s->value > 0) {
s->value++;
spinlock_unlock(&s->lock);
spinlock_irqsave_unlock(&s->lock);
} else {
unsigned int k, i;
@ -153,7 +200,7 @@ inline static int sem_post(sem_t* s) {
}
i = (i + 1) % MAX_TASKS;
}
spinlock_unlock(&s->lock);
spinlock_irqsave_unlock(&s->lock);
}
return 0;

View file

@ -41,11 +41,11 @@ typedef struct {
/// Position in queue
unsigned int pos;
/// Access lock
spinlock_t lock;
spinlock_irqsave_t lock;
} sem_t;
/// Macro for initialization of semaphore
#define SEM_INIT(v) {v, {[0 ... MAX_TASKS-1] = MAX_TASKS}, 0, SPINLOCK_INIT}
#define SEM_INIT(v) {v, {[0 ... MAX_TASKS-1] = MAX_TASKS}, 0, SPINLOCK_IRQSAVE_INIT}
#ifdef __cplusplus
}

View file

@ -1,20 +1,36 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
* This file is part of MetalSVM.
*/
/**
@ -50,6 +66,14 @@ extern "C" {
#define __NR_wait 13
#define __NR_execve 14
#define __NR_times 15
#define __NR_accept 16
#define __NR_bind 17
#define __NR_closesocket 18
#define __NR_connect 19
#define __NR_listen 20
#define __NR_recv 21
#define __NR_send 22
#define __NR_socket 23
#ifdef __cplusplus
}

View file

@ -100,13 +100,6 @@ void scheduler(void);
*/
int wakeup_task(tid_t);
/** @brief Change a task's status to TASK_BLOCKED
* @return
* - 0 on success
* - -EINVAL (-22) on failure
*/
int block_task(tid_t);
/** @brief Abort current task */
void NORETURN abort(void);

View file

@ -41,15 +41,17 @@ extern "C" {
#endif
#define TASK_INVALID 0
#define TASK_READY 1
#define TASK_READY 1
#define TASK_RUNNING 2
#define TASK_BLOCKED 3
#define TASK_FINISHED 4
#define TASK_IDLE 5
#define TASK_IDLE 5
#define TASK_DEFAULT_FLAGS 0
#define TASK_FPU_INIT (1 << 0)
#define TASK_FPU_USED (1 << 1)
#define TASK_TIMER_USED (1 << 2)
#define TASK_SWITCH_IN_PROGRESS (1 << 3)
typedef int (*entry_point_t)(void*);
typedef int (STDCALL *internal_entry_point_t)(void*);
@ -61,8 +63,14 @@ typedef struct task {
tid_t id;
/// Task status (INVALID, READY, RUNNING, ...)
uint32_t status;
/// Additional status flags. For instance, to signalize the using of the FPU
uint32_t flags;
/// Number of used time slices
uint32_t time_slices;
/// timeout for a blocked task
uint64_t timeout;
/// Usage in number of pages
atomic_int32_t user_usage;
atomic_int32_t user_usage;
/// Avoids concurrent access to the page directory
spinlock_t pgd_lock;
/// pointer to the page directory
@ -71,21 +79,23 @@ typedef struct task {
spinlock_t vma_lock;
/// List of VMAs
vma_t* vma_list;
/// Additional status flags. For instance, to signalize the using of the FPU
uint32_t flags;
/// starting time/tick of the task
uint64_t start_tick;
/// Start address of the heap
uint32_t start_heap;
/// End address of the heap
uint32_t end_heap;
#ifdef CONFIG_LWIP
/// LwIP error code
int lwip_err;
#endif
/// Mail inbox
mailbox_wait_msg_t inbox;
/// Mail outbox array
mailbox_wait_msg_t* outbox[MAX_TASKS];
/// FPU state
union fpu_state fpu;
} __attribute__((packed)) task_t;
} task_t;
#ifdef __cplusplus
}

View file

@ -56,13 +56,13 @@ int sys_times(struct tms*, clock_t* clock);
*/
int timer_init(void);
/** @brief Blocking wait function
*
* This function does no busy-wait.
/** @brief Initialized a timer
*
* @param ticks Amount of ticks to wait
* @return
* - 0 on success
*/
void timer_wait(unsigned int ticks);
int timer_wait(unsigned int ticks);
/** @brief Returns the current number of ticks.
* @return Current number of ticks

View file

@ -1,4 +1,4 @@
C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c
C_source := main.c tasks.c syscall.c tests.c echo.c ping.c netio.c init.c server.c client.c shell.c
MODULE := kernel
include $(TOPDIR)/Makefile.inc

120
kernel/client.c Normal file
View file

@ -0,0 +1,120 @@
#include "client.h"
#include "../drivers/net/util.h"
#define SOCKET_ERROR -1
int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen)
{
int iResult;
ClientEventArgs e;
//abfragen ob client existiert!! wichtig
if (cli->sSocket != SOCKET_ERROR)
{
iResult= send(cli->sSocket,(char*)pBuffer,bufferlen,0);
if (cli->_OnWrite != 0)
{
e.dwLen = iResult;
e.pBuffer = pBuffer;
cli->_OnWrite(&e);
}
return iResult;
}
else
return -3;
}
int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse)
{
ClientEventArgs e;
cli->sSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Einen Socket erstellen
cli->wPort=Port;
cli->adAddr.sin_port = htons(cli->wPort);
if (cli->sSocket == SOCKET_ERROR)
return -2;
if (webAdresse) //Fall es sich um eine Internet Adresse Handelt
return -1;
else //Fall es sich um eine LAN Adresse im 127.0.0.1 Stil handelt
cli->adAddr.sin_addr.s_addr = inet_addr(pAdresse);
if (connect(cli->sSocket,(const struct sockaddr*)&cli->adAddr, sizeof(cli->adAddr))==0)
{
create_kernel_task(&cli->bThread,cli_WaitForPacket,cli);
if (cli->_OnConnect != 0)
{
e.dwLen = 0;
e.pBuffer = 0;
cli->_OnConnect(&e);
}
return 0;
}
else
return -1;
};
int cli_DisconnectFrom(Client* cli)
{
shutdown(cli->sSocket,2);
closesocket(cli->sSocket);
cli->sSocket = SOCKET_ERROR;
return 0;
}
void cli_WaitForPacket(Client* cli)
{
int iResult=1;
char pTmpBuffer[DEF_BUFFERSIZE+1];
ClientEventArgs e;
while (iResult > 0)
{
iResult = recv(cli->sSocket ,pTmpBuffer, DEF_BUFFERSIZE, 0);
if (iResult > 0)
{
pTmpBuffer[iResult]='\0';
if (cli->_OnRead != 0)
{
e.dwLen = iResult;
e.pBuffer = pTmpBuffer;
cli->_OnRead( &e);
}
}
else //Verbindung geschlossen
{
cli->sSocket=SOCKET_ERROR;
if (cli->_OnDisconnect != 0)
{
e.dwLen = 0;
e.pBuffer = 0;
cli->_OnDisconnect( &e);
}
}
}
};
int cli_init(Client* cli)
{
cli->_OnConnect = 0;
cli->_OnWrite = 0;
cli->_OnRead = 0;
cli->_OnDisconnect = 0;
cli->adAddr.sin_addr.s_addr = INADDR_ANY; // IP'S die der Client annehmen soll
cli->adAddr.sin_family = AF_INET; // AdressFamilie (TCP/IP)
// adAddr.sin_port = htons(iPort); // Port auf dem der Client erreichbar seien soll
return NULL;
}
int cli_destroy(Client* cli)
{
closesocket(cli->sSocket);;
return NULL;
}

56
kernel/client.h Normal file
View file

@ -0,0 +1,56 @@
#ifndef __CLIENT__
#define __CLIENT__
#define DEF_BUFFERSIZE 2048 // Buffergröße für ein Packet
#ifndef LWIP_SOCKET
#include <lwip/sockets.h>
#endif
#ifndef SOCKET
#define SOCKET int
#endif
#include <metalsvm/tasks.h>
typedef struct _ClientEventArgs
{
unsigned int dwLen;
void* pBuffer;
} ClientEventArgs;
typedef void (*ClientEventHandler)(ClientEventArgs*);
typedef struct _Client
{
//Connection Handling
SOCKET sSocket;
struct sockaddr_in adAddr;
//Output Interfacte
unsigned short wPort;
tid_t bThread;
// Eventhandling
ClientEventHandler _OnConnect;
ClientEventHandler _OnDisconnect;
ClientEventHandler _OnRead;
ClientEventHandler _OnWrite;
} Client;
int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen);
int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse);
int cli_DisconnectFrom(Client* cli);
void cli_WaitForPacket(Client* cli);
cli_init(Client* cli);
cli_destroy(Client* cli);
#endif

View file

@ -25,6 +25,7 @@
#include <metalsvm/tasks.h>
#include <metalsvm/errno.h>
#include <metalsvm/init.h>
#include <metalsvm/fs.h>
#ifdef CONFIG_LWIP
#include <lwip/init.h>
#include <lwip/sys.h>
@ -47,6 +48,8 @@
void echo_init(void);
void ping_init(void);
void netio_init(void);
int test_init(void);
/*
* Note that linker symbols are not variables, they have no memory allocated for
@ -150,12 +153,13 @@ int network_init(void)
}
}
#else
//mmnif_open();
mmnif_open();
#endif
// start echo and ping server
echo_init();
ping_init();
//ping_init();
netio_init();
#endif
return 0;
@ -165,7 +169,7 @@ int network_shutdown(void)
{
#ifdef CONFIG_LWIP
#ifdef CONFIG_ROCKCREEK
//mmnif_close();
mmnif_close();
#elif defined(CONFIG_PCI)
dhcp_release(default_netif);
dhcp_stop(default_netif);
@ -178,4 +182,45 @@ int network_shutdown(void)
return 0;
}
static void list_fs(vfs_node_t* node, uint32_t depth)
{
int j, i = 0;
dirent_t* dirent = NULL;
while ((dirent = readdir_fs(node, i)) != 0) {
for(j=0; j<depth; j++)
kputs(" ");
kprintf("%s\n", dirent->name);
if (strcmp(dirent->name, ".") && strcmp(dirent->name, "..")) {
vfs_node_t *new_node = finddir_fs(node, dirent->name);
if (new_node) {
if (new_node->type == FS_FILE) {
char buff[16] = {[0 ... 15] = 0x00};
read_fs(new_node, (uint8_t*)buff, 8, 0);
for(j=0; j<depth+1; j++)
kputs(" ");
kprintf("content: %s\n", buff);
} else list_fs(new_node, depth+1);
}
}
i++;
}
}
static void list_root(void) {
kprintf("List of the file system:\n/\n");
list_fs(fs_root, 1);
}
int initd(void* arg)
{
network_init();
list_root();
test_init();
return 0;
}

View file

@ -24,9 +24,9 @@
#include <metalsvm/mmu.h>
#include <metalsvm/tasks.h>
#include <metalsvm/processor.h>
#include <metalsvm/fs.h>
#include <metalsvm/errno.h>
#include <metalsvm/init.h>
#include <metalsvm/fs.h>
#include <asm/irq.h>
#include <asm/irqflags.h>
#include <asm/kb.h>
@ -34,8 +34,6 @@
#include <asm/icc.h>
#endif
extern int test_init(void);
/*
* Note that linker symbols are not variables, they have no memory allocated for
* maintaining a value, rather their address is their value.
@ -45,39 +43,6 @@ extern const void kernel_end;
extern char __BUILD_DATE;
extern char __BUILD_TIME;
static void list_fs(vfs_node_t* node, uint32_t depth)
{
int j, i = 0;
dirent_t* dirent = NULL;
while ((dirent = readdir_fs(node, i)) != 0) {
for(j=0; j<depth; j++)
kputs(" ");
kprintf("%s\n", dirent->name);
if (strcmp(dirent->name, ".") && strcmp(dirent->name, "..")) {
vfs_node_t *new_node = finddir_fs(node, dirent->name);
if (new_node) {
if (new_node->type == FS_FILE) {
char buff[16] = {[0 ... 15] = 0x00};
read_fs(new_node, (uint8_t*)buff, 8, 0);
for(j=0; j<depth+1; j++)
kputs(" ");
kprintf("content: %s\n", buff);
} else list_fs(new_node, depth+1);
}
}
i++;
}
}
static void list_root(void) {
kprintf("List of the file system:\n/\n");
list_fs(fs_root, 1);
}
#if MAX_CORES > 1
// idle loop of the application processors
int smp_main(void)
@ -117,7 +82,6 @@ int main(void)
kprintf("Kernel starts at %p and ends at %p\n", &kernel_start, &kernel_end);
system_calibration();
network_init();
kprintf("Processor frequency: %u MHz\n", get_cpu_frequency());
kprintf("Total memory: %u MBytes\n", atomic_int32_read(&total_pages)/((1024*1024)/PAGE_SIZE));
@ -125,9 +89,8 @@ int main(void)
kprintf("Current available memory: %u MBytes\n", atomic_int32_read(&total_available_pages)/((1024*1024)/PAGE_SIZE));
sleep(5);
list_root();
test_init();
per_core(current_task)->status = TASK_IDLE;
create_kernel_task(NULL, initd, NULL);
per_core(current_task)->time_slices = 0; // reset the number of time slices
reschedule();
while(1) {

62
kernel/netio.c Normal file
View file

@ -0,0 +1,62 @@
/*
* this example is derived from the netio example of the contrib-1.4.0
*
* see http://download.savannah.gnu.org/releases/lwip/
*/
#include <metalsvm/stddef.h>
#include <lwip/opt.h>
#if defined(CONFIG_LWIP)
#include <lwip/opt.h>
#include <lwip/tcp.h>
/* See http://www.nwlab.net/art/netio/netio.html to get the netio tool */
#if LWIP_TCP
static err_t netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
LWIP_UNUSED_ARG(arg);
if (err == ERR_OK && p != NULL) {
tcp_recved(pcb, p->tot_len);
pbuf_free(p);
} else {
pbuf_free(p);
}
if (err == ERR_OK && p == NULL) {
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_close(pcb);
}
return ERR_OK;
}
static err_t netio_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(err);
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, netio_recv);
return ERR_OK;
}
void netio_init(void)
{
struct tcp_pcb *pcb;
pcb = tcp_new();
tcp_bind(pcb, IP_ADDR_ANY, 18767);
pcb = tcp_listen(pcb);
tcp_accept(pcb, netio_accept);
}
#endif /* LWIP_TCP */
#endif

199
kernel/server.c Normal file
View file

@ -0,0 +1,199 @@
#include "server.h"
typedef int UINT_PTR;
#define SOCKET_ERROR -1
int srv_sendBuffer(Server* srv, unsigned int cli,void* pBuffer, unsigned int dwLen)
{
int result;
ServerEventArgs e;
//abfragen ob client existiert!! wichtig
if (srv->sConnections[cli] != SOCKET_ERROR)
{
result= send(srv->sConnections[cli],(char*)pBuffer,dwLen,0);
if (srv->_OnWrite!=0)
{
e.ClientID = cli;
e.dwLen = dwLen;
e.pBuffer = pBuffer;
srv->_OnWrite(&e);
}
return result;
}
else
return -1;
}
void srv_DisconnectClient(Server* srv, unsigned int cli)
{
ServerEventArgs e;
closesocket(srv->sConnections[cli]);
srv->sConnections[cli]=SOCKET_ERROR;
srv->dwConnections--;
if (srv->_OnDisconnect!=0)
{
e.ClientID = cli;
e.dwLen = 0;
e.pBuffer = 0;
srv->_OnDisconnect(&e);
}
memset(&srv->ConnectionsAddr[cli],0,sizeof(struct sockaddr_in));
}
void* srv_WaitForConnection(Server* srv)
{
SOCKET tmpClient;
struct sockaddr_in tmpAddr;
int tmpAddrLen;
ServerEventArgs e;
ServerThreadArgs* t;
unsigned int i;
do
{
if (srv->dwConnections < srv->dwMaximumConnections)
{
tmpAddrLen = sizeof(struct sockaddr);
if ((tmpClient=accept(srv->sSocket,(struct sockaddr*)&tmpAddr,&tmpAddrLen)) != SOCKET_ERROR)
{
for(i=0;i<srv->dwMaximumConnections;i++)
{
if (srv->sConnections[i] == SOCKET_ERROR)
{
srv->sConnections[i] = tmpClient;
srv->ConnectionsAddr[i] = tmpAddr;
srv->dwConnections++;
if(srv->_OnConnect!=0)
{
e.ClientID = i;
e.dwLen = 0;
e.pBuffer =0;
srv->_OnConnect(&e);
}
t = (ServerThreadArgs*) kmalloc(sizeof(ServerThreadArgs));
t->ID = i;
t->srv = srv;
create_kernel_task(&srv->bThreads[i],srv_WaitForPacket,t);
break;
}
}
}
}
else
{
}
}while(1);
return NULL;
}
void* srv_WaitForPacket(ServerThreadArgs* t)
{
int iResult=1;
char pTmpBuffer[DEF_BUFFERSIZE+1];
ServerEventArgs e;
Server* srv = t->srv;
int cli = t->ID;
while (iResult > 0)
{
iResult = recv(srv->sConnections[cli] ,pTmpBuffer, DEF_BUFFERSIZE, 0);
if (iResult > 0)
{
pTmpBuffer[iResult]='\0';
if(srv->_OnRead!=0)
{
e.ClientID = cli;
e.dwLen = iResult;
e.pBuffer = pTmpBuffer;
srv->_OnRead(&e);
}
}
else //Verbindung geschlossen
{
closesocket(srv->sConnections[cli]);
srv->sConnections[cli]=SOCKET_ERROR;
if(srv->_OnDisconnect!=0)
{
e.ClientID = cli;
e.dwLen = 0;
e.pBuffer = 0;
srv->_OnDisconnect(&e);
}
memset(&srv->ConnectionsAddr[cli],0,sizeof(struct sockaddr_in));
srv->dwConnections--;
iResult=-1;
}
}
return NULL;
}
int server_init(Server* srv, unsigned short Port, unsigned int dwMaxConnections)
{
struct sockaddr_in tmpAddr;
int tmpAddrLen;
ServerThreadArgs t;
tmpAddrLen = sizeof(struct sockaddr);
// Unregister Events
srv->_OnConnect=0;
srv->_OnRead=0;
srv->_OnDisconnect=0;
srv->_OnWrite=0;
// Allocate needed Memory
srv->sConnections=(SOCKET*)kmalloc(sizeof(SOCKET)*dwMaxConnections);
srv->ConnectionsAddr =(struct sockaddr_in*) kmalloc(sizeof(struct sockaddr_in)*dwMaxConnections);
srv->bThreads = (tid_t*)kmalloc(sizeof(tid_t)*dwMaxConnections);
if (!srv->sConnections || !srv->ConnectionsAddr || !srv->bThreads)
{
kprintf("low on mem -%d- -%d- -%d-",srv->sConnections ,srv->ConnectionsAddr,srv->bThreads);
return -1;
}
srv->dwMaximumConnections=dwMaxConnections;
memset(srv->sConnections,0xFF,sizeof(SOCKET)*dwMaxConnections);
memset(srv->ConnectionsAddr,0x00,sizeof(struct sockaddr_in)*dwMaxConnections);
srv->dwConnections=0;
srv->wPort = Port;
srv->adAddr.sin_addr.s_addr = INADDR_ANY; // IP'S die der Server annehmen soll
srv->adAddr.sin_family = AF_INET; // AdressFamilie (TCP/IP)
srv->adAddr.sin_port = htons(srv->wPort); // Port auf dem der server erreichbar seien soll
srv->sSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Einen Socket erstellen
bind( srv->sSocket,(const struct sockaddr *) &srv->adAddr, sizeof(srv->adAddr)); // Der Server an die Adresse binden;
listen(srv->sSocket,srv->dwMaximumConnections); // Den Server in listenig State versetzen
create_kernel_task(&srv->bThread_listen,srv_WaitForConnection,srv);
// sConnections[0] = accept(sSocket,(struct sockaddr*)&tmpAddr,&tmpAddrLen);
// t.ID = 0;
// bthread_create(&bThreads[0],NULL,(start_routine) srv_WaitForPacket,&t);
}
int server_destroy(Server* srv)
{
unsigned int i;
for (i=0;i<srv->dwMaximumConnections;i++)
{
if (srv->sConnections[i] != SOCKET_ERROR)closesocket(srv->sConnections[i]);
//bthread_terminate(&srv->bThreads[i],0x00);
}
closesocket(srv->sSocket);
//bthread_terminate(&srv->bThread_listen,0x00);
// free(srv->sConnections);
// free(srv->ConnectionsAddr);
// free(srv->bThreads);
}

67
kernel/server.h Normal file
View file

@ -0,0 +1,67 @@
#ifndef __SERVER__
#define __SERVER__
#ifdef WIN32
#include <system/threads/bthread.h>
#else
#include <metalsvm/tasks.h>
#endif
#ifndef LWIP_SOCKET
#include <lwip/sockets.h>
#endif
typedef struct _ServerEventArgs
{
unsigned int ClientID;
unsigned int dwLen;
void* pBuffer;
} ServerEventArgs;
#define DEF_BUFFERSIZE 2048
typedef void (*ServerEventHandler)(ServerEventArgs*);
#ifndef SOCKET
#define SOCKET int
#endif
typedef struct _Server
{
SOCKET sSocket;
unsigned int* sConnections;
struct sockaddr_in adAddr;
unsigned short wPort;
unsigned int dwConnections;
unsigned int dwMaximumConnections;
struct sockaddr_in* ConnectionsAddr;
tid_t bThread_listen;
tid_t* bThreads;
ServerEventHandler _OnConnect;
ServerEventHandler _OnDisconnect;
ServerEventHandler _OnRead;
ServerEventHandler _OnWrite;
} Server;
typedef struct _ServerThreadArgs
{
Server* srv;
unsigned int ID;
} ServerThreadArgs;
int srv_sendBuffer(Server* srv,unsigned int cli,void* pBuffer, unsigned int dwLen);
void srv_DisconnectClient(Server* srv,unsigned int cli);
void* srv_WaitForConnection(Server* srv);
void* srv_WaitForPacket(ServerThreadArgs* t);
int server_init(Server* srv,unsigned short Port, unsigned int dwMaxConnections);
int server_destroy(Server* srv);
#endif

76
kernel/shell.c Normal file
View file

@ -0,0 +1,76 @@
#include "shell.h"
#include "server.h"
#include "client.h"
#include <metalsvm/time.h>
static Server srv;
static int emac_id = -1;
static Client cli;
static int iamsrv = 0;
char shellbuffer[512];
void shelldebugprint(char* x)
{
kprintf("debugprinting : %s",x);
if (iamsrv)
srv_sendBuffer(&srv,emac_id,x,strlen(x));
else
cli_sendBuffer(&cli,x,strlen(x));
}
void shell_on_connect(ServerEventArgs* e)
{
kprintf("connection from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port));
kprintf("connehx: 0x%.8X",srv.ConnectionsAddr[e->ClientID].sin_addr);
// if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001)
if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xFE04A8C0)
{
emac_id = e->ClientID;
kprintf("bmc connected");
}
else
kprintf("link engaged\n");
}
void shell_on_disconnect(ServerEventArgs* e)
{
kprintf("connection lost from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port));
}
void shell_on_read(ServerEventArgs* e)
{
if (emac_id != -1 && e->ClientID != emac_id)
srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen);
else
// else commandos oder so
srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen);
}
void shell_init(int srv_or_cli)
{
if (!srv_or_cli)
{
iamsrv = 1;
kprintf("server init");
server_init(&srv,23,49);
srv._OnConnect = shell_on_connect;
srv._OnDisconnect = shell_on_disconnect;
srv._OnRead = shell_on_read;
}
else
{
sleep(3);
kprintf("client init");
cli_init(&cli);
while (cli_ConnectTo(&cli,"192.168.0.1",23,0));
sleep(1);
}
}

14
kernel/shell.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef SHELL_H
#define SHELL_H
#include <metalsvm/stdio.h>
void shelldebugprint(char* x);
void shell_init(int srv_or_cli);
extern char shellbuffer[512];
#define SHELLDEBUGPRINTF(x,...) ksnprintf(shellbuffer,sizeof(shellbuffer),x,##__VA_ARGS__);shelldebugprint(shellbuffer);
#endif // SHELL_H

View file

@ -24,6 +24,27 @@
#include <metalsvm/errno.h>
#include <metalsvm/spinlock.h>
#include <metalsvm/time.h>
#include <lwip/opt.h>
#if defined(CONFIG_LWIP) && LWIP_SOCKET
#include <lwip/mem.h>
#include <lwip/raw.h>
#include <lwip/icmp.h>
#include <lwip/netif.h>
#include <lwip/sys.h>
#include <lwip/timers.h>
#include <lwip/inet_chksum.h>
#include <lwip/ip.h>
#include <lwip/sockets.h>
#include <lwip/inet.h>
#include <lwip/err.h>
/*
* We set the a bit LWIP_FD_BIT to determine,
* if the descriptor belongs to LwIP or MetalSVM.
*/
#define LWIP_FD_BIT (1 << 28)
#endif
static int sys_write(int fildes, const char *buf, size_t len)
{
@ -85,15 +106,33 @@ int syscall_handler(uint32_t sys_nr, ...)
const char* buf = va_arg(vl, const char*);
size_t len = va_arg(vl, size_t);
#if defined(CONFIG_LWIP) && LWIP_SOCKET
if (fildes & LWIP_FD_BIT) {
ret = lwip_write(fildes & ~LWIP_FD_BIT, buf, len);
if (ret < 0)
ret = -errno;
} else ret = sys_write(fildes, buf, len);
#else
ret = sys_write(fildes, buf, len);
#endif
break;
}
case __NR_open:
ret = 1;
break;
case __NR_close:
case __NR_close: {
#if defined(CONFIG_LWIP) && LWIP_SOCKET
int s = va_arg(vl, int);
if (s & LWIP_FD_BIT) {
ret = lwip_close(s & ~LWIP_FD_BIT);
if (ret < 0)
ret = -errno;
} else ret = 0;
#else
ret = 0;
#endif
break;
}
case __NR_sbrk: {
int incr = va_arg(vl, int);
@ -127,6 +166,109 @@ int syscall_handler(uint32_t sys_nr, ...)
ret = sys_times(buffer, clock);
break;
}
#if defined(CONFIG_LWIP) && LWIP_SOCKET
case __NR_read: {
int s = va_arg(vl, int);
void* mem = va_arg(vl, void*);
size_t len = va_arg(vl, size_t);
if (!(s & LWIP_FD_BIT)) {
ret = -ENOTSOCK;
break;
}
ret = lwip_read(s & ~LWIP_FD_BIT, mem, len);
if (ret < 0)
ret = -errno;
break;
}
case __NR_closesocket: {
int s = va_arg(vl, int);
if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) {
ret = -ENOTSOCK;
break;
}
ret = lwip_close(s & ~LWIP_FD_BIT);
if (ret < 0)
ret = -errno;
break;
}
case __NR_socket: {
int domain = va_arg(vl, int);
int type = va_arg(vl, int);
int protocol = va_arg(vl, int);
ret = lwip_socket(domain, type, protocol);
if (ret >= 0)
ret |= LWIP_FD_BIT;
else
ret = -errno;
break;
}
case __NR_connect: {
int s = va_arg(vl, int);
const struct sockaddr* name = va_arg(vl, const struct sockaddr*);
socklen_t namelen = va_arg(vl, socklen_t);
if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) {
ret = -ENOTSOCK;
break;
}
ret = lwip_connect(s & ~LWIP_FD_BIT, name, namelen);
if (ret < 0)
ret = -errno;
break;
}
case __NR_bind: {
int s = va_arg(vl, int);
const struct sockaddr* name = va_arg(vl, const struct sockaddr*);
socklen_t namelen = va_arg(vl, socklen_t);
if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) {
ret = -ENOTSOCK;
break;
}
ret = lwip_bind(s & ~LWIP_FD_BIT, name, namelen);
if (ret < 0)
ret = -errno;
break;
}
case __NR_listen:{
int s = va_arg(vl, int);
int backlog = va_arg(vl, int);
if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) {
ret = -ENOTSOCK;
break;
}
ret = lwip_listen(s & ~LWIP_FD_BIT, backlog);
if (ret < 0)
ret = -errno;
break;
}
case __NR_accept: {
int s = va_arg(vl, int);
struct sockaddr* addr = va_arg(vl, struct sockaddr*);
socklen_t* addrlen = va_arg(vl, socklen_t*);
if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) {
ret = -ENOTSOCK;
break;
}
ret = lwip_accept(s & ~LWIP_FD_BIT, addr, addrlen);
if (ret >= 0)
ret |= LWIP_FD_BIT;
else
ret = -errno;
break;
}
#endif
default:
kputs("invalid system call\n");
ret = -ENOSYS;

View file

@ -47,8 +47,8 @@
* A task's id will be its position in this array.
*/
static task_t task_table[MAX_TASKS] = { \
[0] = {0, TASK_RUNNING, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}, \
[1 ... MAX_TASKS-1] = {0, TASK_INVALID, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}};
[0] = {0, TASK_IDLE, 0, 0, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}, \
[1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, 0, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}};
static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT;
DEFINE_PER_CORE(task_t*, current_task, task_table+0);
@ -63,16 +63,36 @@ task_t* get_current_task(void) {
return per_core(current_task);
}
int multitasking_init(void) {
if (BUILTIN_EXPECT(task_table[0].status == TASK_RUNNING, 1)) {
mailbox_wait_msg_init(&task_table[0].inbox);
memset(task_table[0].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS);
task_table[0].pgd = get_boot_pgd();
task_table[0].flags = TASK_DEFAULT_FLAGS;
return 0;
int dump_scheduling_statistics(void)
{
uint32_t i;
uint32_t id = 0;
kprintf("Scheduling statistics:\n");
kprintf("======================\n");
kprintf("total ticks:\t%llu\n", get_clock_tick());
for(i=0; i<MAX_CORES; i++) {
if (task_table[i].status == TASK_IDLE) {
kprintf("core %d :\t%u idle slices\n", id, task_table[i].time_slices);
id++;
}
}
return -ENOMEM;
return 0;
}
int multitasking_init(void) {
if (BUILTIN_EXPECT(task_table[0].status != TASK_IDLE, 0)) {
kputs("Task 0 is not an idle task\n");
return -ENOMEM;
}
mailbox_wait_msg_init(&task_table[0].inbox);
memset(task_table[0].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS);
task_table[0].pgd = get_boot_pgd();
task_table[0].flags = TASK_DEFAULT_FLAGS;
return 0;
}
size_t get_idle_task(uint32_t id)
@ -83,11 +103,12 @@ size_t get_idle_task(uint32_t id)
task_table[id].id = id;
task_table[id].status = TASK_IDLE;
task_table[id].flags = TASK_DEFAULT_FLAGS;
task_table[id].time_slices = 0;
atomic_int32_set(&task_table[id].user_usage, 0);
mailbox_wait_msg_init(&task_table[id].inbox);
memset(task_table[id].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS);
task_table[id].pgd = get_boot_pgd();
task_table[id].flags = TASK_DEFAULT_FLAGS;
current_task[id].var = task_table+id;
return get_stack(id);
@ -173,17 +194,6 @@ void NORETURN abort(void) {
do_exit(-1);
}
/*
* @brief: if the task gets the first time slice,
* the table_lock is hold and have to be released.
*/
inline static void start_first_time_slice(void)
{
#if MAX_CORES > 1
spinlock_irqsave_unlock(&table_lock);
#endif
}
/** @brief Create a task with a specific entry point
*
* @param id Pointer to a tid_t struct were the id shall be set
@ -217,6 +227,9 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg)
}
task_table[i].id = i;
task_table[i].status = TASK_READY;
task_table[i].flags = TASK_DEFAULT_FLAGS;
task_table[i].time_slices = 0;
spinlock_init(&task_table[i].vma_lock);
task_table[i].vma_list = NULL;
mailbox_wait_msg_init(&task_table[i].inbox);
@ -228,11 +241,12 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg)
ret = create_default_frame(task_table+i, ep, arg);
task_table[i].flags = TASK_DEFAULT_FLAGS;
task_table[i].start_heap = 0;
task_table[i].end_heap = 0;
#ifdef CONFIG_LWIP
task_table[i].lwip_err = 0;
#endif
task_table[i].start_tick = get_clock_tick();
task_table[i].status = TASK_READY;
break;
}
}
@ -292,11 +306,14 @@ int sys_fork(void)
mailbox_wait_msg_init(&task_table[i].inbox);
memset(task_table[i].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS);
task_table[i].outbox[parent_task->id] = &parent_task->inbox;
task_table[i].flags = parent_task->flags;
task_table[i].flags = parent_task->flags & ~TASK_SWITCH_IN_PROGRESS;
memcpy(&(task_table[i].fpu), &(parent_task->fpu), sizeof(union fpu_state));
task_table[i].start_tick = get_clock_tick();
task_table[i].start_heap = 0;
task_table[i].end_heap = 0;
#ifdef CONFIG_LWIP
task_table[i].lwip_err = 0;
#endif
ret = arch_fork(task_table+i);
@ -305,7 +322,13 @@ int sys_fork(void)
// Leave the function without releasing the locks
// because the locks are already released
// by the parent task!
start_first_time_slice();
#if MAX_CORES > 1
task_t* old = per_core(old_task);
if (old)
old->flags &= ~TASK_SWITCH_IN_PROGRESS;
#endif
irq_enable();
return 0;
}
@ -339,8 +362,13 @@ static int STDCALL kernel_entry(void* args)
{
int ret;
kernel_args_t* kernel_args = (kernel_args_t*) args;
#if MAX_CORES > 1
task_t* old = per_core(old_task);
start_first_time_slice();
if (old)
old->flags &= ~TASK_SWITCH_IN_PROGRESS;
#endif
irq_enable();
if (BUILTIN_EXPECT(!kernel_args, 0))
return -EINVAL;
@ -395,6 +423,7 @@ static int load_task(load_args_t* largs)
//elf_section_header_t sec_header;
vfs_node_t* node;
task_t* curr_task = per_core(current_task);
int err;
if (!largs)
return -EINVAL;
@ -403,7 +432,12 @@ static int load_task(load_args_t* largs)
if (!node)
return -EINVAL;
read_fs(node, (uint8_t*)&header, sizeof(elf_header_t), 0);
err = read_fs(node, (uint8_t*)&header, sizeof(elf_header_t), 0);
if (err < 0) {
kprintf("read_fs failed: %d\n", err);
return err;
}
if (BUILTIN_EXPECT(header.ident.magic != ELF_MAGIC, 0))
goto invalid;
@ -571,6 +605,12 @@ static int load_task(load_args_t* largs)
invalid:
kprintf("Invalid executable!\n");
kprintf("magic number 0x%x\n", (uint32_t) header.ident.magic);
kprintf("header type 0x%x\n", (uint32_t) header.type);
kprintf("machine type 0x%x\n", (uint32_t) header.machine);
kprintf("elf ident class 0x%x\n", (uint32_t) header.ident._class);
kprintf("elf identdata !0x%x\n", header.ident.data);
kprintf("program entry point 0x%x\n", (size_t) header.entry);
return -EINVAL;
}
@ -580,8 +620,13 @@ invalid:
static int STDCALL user_entry(void* arg)
{
int ret;
#if MAX_CORES > 1
task_t* old = per_core(old_task);
start_first_time_slice();
if (old)
old->flags &= ~TASK_SWITCH_IN_PROGRESS;
#endif
irq_enable();
if (BUILTIN_EXPECT(!arg, 0))
return -EINVAL;
@ -734,7 +779,7 @@ tid_t wait(int32_t* result)
if (BUILTIN_EXPECT(curr_task->status == TASK_IDLE, 0))
return -EINVAL;
mailbox_wait_msg_fetch(&curr_task->inbox, &tmp);
mailbox_wait_msg_fetch(&curr_task->inbox, &tmp, 0);
if (result)
*result = tmp.result;
@ -752,12 +797,9 @@ int wakeup_task(tid_t id)
{
int ret = -EINVAL;
/* avoid nested locking */
spinlock_irqsave_lock(&table_lock);
if (task_table[id].status != TASK_BLOCKED) {
kprintf("Task %d is not blocked!\n", id);
} else {
if (task_table[id].status == TASK_BLOCKED) {
task_table[id].status = TASK_READY;
ret = 0;
}
@ -767,27 +809,14 @@ int wakeup_task(tid_t id)
return ret;
}
/** @brief Block a running or ready task.
* @param id The task's tid_t structure
* @return
* - 0 on success
* - -EINVAL (-22) on failure
/*
* we use this struct to guarantee that the id
* has its own cache line
*/
int block_task(tid_t id)
{
int ret = -EINVAL;
spinlock_irqsave_lock(&table_lock);
if ((task_table[id].status == TASK_RUNNING) || (task_table[id].status == TASK_READY)) {
task_table[id].status = TASK_BLOCKED;
ret = 0;
} else kprintf("Unable to block task %d!\n", id);
spinlock_irqsave_unlock(&table_lock);
return ret;
}
typedef struct {
uint32_t id __attribute__ ((aligned (CACHE_LINE)));
uint8_t gap[CACHE_LINE-sizeof(uint32_t)];
} last_id_t;
/** @brief _The_ scheduler procedure
*
@ -797,15 +826,20 @@ void scheduler(void)
{
task_t* orig_task;
task_t* curr_task;
unsigned int i;
unsigned int new_id;
uint32_t i;
uint32_t new_id;
uint64_t current_tick;
static last_id_t last_id = { 0 };
#if MAX_CORES > 1
spinlock_irqsave_lock(&table_lock);
#endif
current_tick = get_clock_tick();
orig_task = curr_task = per_core(current_task);
/* increase the number of used time slices */
curr_task->time_slices++;
/* signalizes that this task could be reused */
if (curr_task->status == TASK_FINISHED)
curr_task->status = TASK_INVALID;
@ -816,19 +850,41 @@ void scheduler(void)
curr_task->flags &= ~TASK_FPU_USED;
}
for(i=1, new_id=(curr_task->id + 1) % MAX_TASKS;
for(i=0, new_id=(last_id.id + 1) % MAX_TASKS;
i<MAX_TASKS; i++, new_id=(new_id+1) % MAX_TASKS)
{
if (task_table[new_id].status == TASK_READY) {
if (curr_task->status == TASK_RUNNING)
if (task_table[new_id].flags & TASK_TIMER_USED) {
if (task_table[new_id].status != TASK_BLOCKED)
task_table[new_id].flags &= ~TASK_TIMER_USED;
if ((task_table[new_id].status == TASK_BLOCKED) && (current_tick >= task_table[new_id].timeout)) {
task_table[new_id].flags &= ~TASK_TIMER_USED;
task_table[new_id].status = TASK_READY;
}
}
if ((task_table[new_id].status == TASK_READY) && !(task_table[new_id].flags & TASK_SWITCH_IN_PROGRESS)) {
if (curr_task->status == TASK_RUNNING) {
curr_task->status = TASK_READY;
#if MAX_CORES > 1
curr_task->flags |= TASK_SWITCH_IN_PROGRESS;
per_core(old_task) = curr_task;
#endif
}
#if MAX_CORES > 1
else per_core(old_task) = NULL;
#endif
task_table[new_id].status = TASK_RUNNING;
curr_task = per_core(current_task) = task_table+new_id;
last_id.id = new_id;
goto get_task_out;
}
}
#if MAX_CORES > 1
per_core(old_task) = NULL;
#endif
if ((curr_task->status == TASK_RUNNING) || (curr_task->status == TASK_IDLE))
goto get_task_out;
@ -840,14 +896,19 @@ void scheduler(void)
curr_task = per_core(current_task) = task_table+CORE_ID;
get_task_out:
//kprintf("schedule %d on core %d\n", per_core(current_task)->id, smp_id());
if (curr_task != orig_task)
switch_task(new_id);
#if MAX_CORES > 1
spinlock_irqsave_unlock(&table_lock);
#endif
if (curr_task != orig_task) {
//kprintf("schedule from %d to %d on core %d\n", orig_task->id, curr_task->id, smp_id());
switch_task(new_id);
#if MAX_CORES > 1
orig_task= per_core(old_task);
if (orig_task)
orig_task->flags &= ~TASK_SWITCH_IN_PROGRESS;
#endif
}
}
void reschedule(void)

View file

@ -33,6 +33,12 @@
#include <asm/SCC_API.h>
#include <lwip/sockets.h>
#include "client.h"
#include "server.h"
#include "shell.h"
#endif
static sem_t consuming, producing;
@ -44,14 +50,14 @@ static int consumer(void* arg)
int i, m = 0;
for(i=0; i<5; i++) {
sem_wait(&consuming);
sem_wait(&consuming, 0);
kprintf("Consumer got %d\n", val);
val = 0;
sem_post(&producing);
}
for(i=0; i<5; i++) {
mailbox_int32_fetch(&mbox, &m);
mailbox_int32_fetch(&mbox, &m, 0);
kprintf("Got mail %d\n", m);
}
@ -64,7 +70,7 @@ static int producer(void* arg)
int mail[5] = {1, 2, 3, 4, 5};
for(i=0; i<5; i++) {
sem_wait(&producing);
sem_wait(&producing, 0);
kprintf("Produce value: current val %d\n", val);
val = 42;
sem_post(&consuming);
@ -125,136 +131,146 @@ static int join_test(void* arg)
}
#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)
static int server_task(void* e)
#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__);
static int srv_cnt = 0;
static Server srv;
void srv_on_read(ServerEventArgs* e)
{
int sockfd, newsockfd, portno, clilen;
char buffer[256];
struct sockaddr_in serv_addr, cli_addr;
int n;
/* First call to socket() function */
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd < 0)
{
kprintf("ERROR opening socket");
return -1;
}
/* Initialize socket structure */
memset((char *) &serv_addr,0, sizeof(serv_addr));
portno = 5001;
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(portno);
kprintf("binding");
/* Now bind the host address using bind() call.*/
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0)
{
kprintf("ERROR on binding");
return -1;
}
/* Now start listening for the clients, here process will
* go in sleep mode and will wait for the incoming connection
*/
kprintf("listening");
listen(sockfd,5);
clilen = sizeof(cli_addr);
/* Accept actual connection from the client */
kprintf("accepting");
newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
if (newsockfd < 0)
{
kprintf("ERROR on accept");
return -1;
}
/* If connection is established then start communicating */
memset(buffer,0,256);
kprintf("recieving");
n = read( newsockfd,buffer, 255);
if (n < 0)
{
kprintf("ERROR reading from socket");
return -1;
}
kprintf("Here is the message: %s\n",buffer);
/* Write a response to the client */
kprintf("writing");
n = write(newsockfd,"I got your message",18);
if (n < 0)
{
kprintf("ERROR writing to socket");
return -1;
}
return 0;
// kprintf("%i:",srv_cnt);
// hex_dump(e->dwLen,e->pBuffer);
// srv_cnt++;
/* printf("%i:",cnt);
puts(e->pBuffer);
puts("\n");
cnt++;
*/
}
static int client_task(void* e)
void srv_on_disc(ServerEventArgs*e )
{
char dir[256];
int sd;
struct sockaddr_in pin;
kprintf("connection lost!!!\n");
}
sleep(1);
void srv_on_conn(ServerEventArgs* e)
{
int i = 0, err = 0;
int tmp1,tmp2;
char buff[1024];
/* fill in the socket structure with host information */
memset(&pin, 0, sizeof(pin));
pin.sin_family = AF_INET;
pin.sin_addr.s_addr = inet_addr("192.168.0.1");
pin.sin_port = htons(5001);
SHELLDEBUGPRINTF("someone finally connected\n");
/* grab an Internet domain socket */
if ((sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
kprintf("socketfail");
return -1;
}
tmp1 = get_clock_tick();
for (i = 0; i < 1024*4; i++)
{
err = srv_sendBuffer(&srv,e->ClientID,buff,sizeof(buff));
if ( err < 0)
{
SHELLDEBUGPRINTF("err: %d", err);
}
kprintf("connecting with socket nr : %d",sd);
/* connect to PORT on HOST */
if (!(i%10))
{
SHELLDEBUGPRINTF("\r-%d-",i);
}
if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) {
kprintf("connectfail");
return -1;
}
kprintf("sending");
/* send a message to the server PORT on machine HOST */
if (send(sd, "HELLO THERE", strlen("HELLO THERE"), 0) == -1) {
kprintf("sendfail");
return -1;
}
kprintf("recieving");
/* wait for a message to come back from the server */
if (recv(sd, dir, 256, 0) == -1) {
kprintf("recvfail");
return -1;
}
}
tmp2 = get_clock_tick();
/* spew-out the results and bail out of here! */
kprintf("%s\n", dir);
// SHELLDEBUGPRINTF("send with %f kb/s",((float)i*sizeof(buff))/(tmp2-tmp1));
SHELLDEBUGPRINTF("send %d bytes in %d ticks",i*sizeof(buff),(tmp2-tmp1));
}
close(sd);
void* server_task(void* e)
{
SHELLDEBUGPRINTF("created server\n");
return 0;
server_init(&srv,5555,2);
srv._OnRead = srv_on_read;
srv._OnDisconnect = srv_on_disc;
srv._OnConnect = srv_on_conn;
while(1)
sleep(2);
return NULL;
}
static int cli_cnt = 0;
void cli_on_read(ClientEventArgs* e)
{
kprintf("\r-%d-",cli_cnt);
cli_cnt++;
// printf("%i:",cnt);
// hex_dump(e->dwLen,e->pBuffer);
// cnt++;
/* puts(e->pBuffer);
puts("\n");
cnt++;
*/
}
void cli_on_disc(ClientEventArgs*e )
{
kprintf("connection lost!!!\n");
}
void* client_task(void* e)
{
int err = -2;
Client cli;
char netbuffer[256];
kprintf("created client");
cli_init(&cli);
cli._OnRead = cli_on_read;
cli._OnDisconnect = cli_on_disc;
sleep(2);
SHELLDEBUGPRINTF("Client is ready...\n");
while (err)
{
sleep(1);
err = cli_ConnectTo(&cli,"192.168.0.1",5555,0);
SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket);
}
SHELLDEBUGPRINTF("connected\n");
sleep(1);
err = cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt"));
SHELLDEBUGPRINTF("send message err = %d\n",err);
while(1)
sleep(2);
return NULL;
}
#endif
int test_init(void)
{
char* argv[] = {"/bin/tests", NULL};
char* server_argv[] = {"/bin/server", "6789", NULL};
char* client_argv[] = {"/bin/client", "127.0.0.1", "6789", NULL};
sem_init(&producing, 1);
sem_init(&consuming, 0);
mailbox_int32_init(&mbox);
#if 0 //defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)
if (!RCCE_ue())
create_kernel_task(NULL,server_task,NULL);
else
create_kernel_task(NULL,client_task,NULL);
#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)
// shell_init(RCCE_ue());
//
// sleep(10);
// SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue());
// if (!RCCE_ue())
// create_kernel_task(NULL,server_task,NULL);
// else
// create_kernel_task(NULL,client_task,NULL);
#endif
create_kernel_task(NULL, foo, "Hello from foo1");
@ -266,6 +282,9 @@ int test_init(void)
create_user_task(NULL, "/bin/tests", argv);
//create_user_task(NULL, "/bin/jacobi", argv);
//create_user_task(NULL, "/bin/jacobi", argv);
create_user_task(NULL, "/bin/server", server_argv);
//sleep(5);
//create_user_task(NULL, "/bin/client", client_argv);
return 0;
}

View file

@ -32,18 +32,22 @@
#define FALSE 0
#endif
#if SYS_LIGHTWEIGHT_PROT
#if MAX_CORES > 1
static spinlock_irqsave_t lwprot_lock;
#endif
#endif
/** Returns the current time in milliseconds,
* may be the same as sys_jiffies or at least based on it. */
u32_t
sys_now(void)
u32_t sys_now(void)
{
return (get_clock_tick() / TIMER_FREQ) * 1000;
return (get_clock_tick() / TIMER_FREQ) * 1000;
}
u32_t
sys_jiffies(void)
u32_t sys_jiffies(void)
{
return (get_clock_tick() / TIMER_FREQ) * 1000;
return (get_clock_tick() / TIMER_FREQ) * 1000;
}
#if !NO_SYS
@ -51,9 +55,13 @@ sys_jiffies(void)
/* sys_init(): init needed system resources
* Note: At the moment there are none
*/
void
sys_init(void)
void sys_init(void)
{
#if SYS_LIGHTWEIGHT_PROT
#if MAX_CORES > 1
spinlock_irqsave_init(&lwprot_lock);
#endif
#endif
}
/**
@ -61,28 +69,24 @@ sys_init(void)
*
* @param ms number of milliseconds to sleep
*/
void
sys_msleep(u32_t ms)
void sys_msleep(u32_t ms)
{
if (ms > 0) {
sys_sem_t delaysem;
err_t err = sys_sem_new(&delaysem, 0);
if (err == ERR_OK) {
sys_arch_sem_wait(&delaysem, ms);
sys_sem_free(&delaysem);
}
}
if (ms * TIMER_FREQ / 1000 > 0)
timer_wait(ms * TIMER_FREQ / 1000);
else if (ms > 0)
udelay(ms * 1000);
}
/* sys_thread_new(): Spawns a new thread with given attributes as supported
* Note: In MetalSVM this is realized as kernel tasks
*/
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg,
int stacksize, int prio)
{
tid_t tmp;
sys_thread_t tmp;
kprintf("Create LWIP task %s\n", name);
create_kernel_task(&tmp,thread,arg);
create_kernel_task(&tmp, thread, arg);
kprintf("Created LWIP task %s with id %u\n", name, tmp);
return tmp;
}
@ -108,10 +112,10 @@ int sys_sem_valid(sys_sem_t* sem)
/* sys_sem_new(): creates a new semaphre with given count.
* This semaphore becomes valid
*/
err_t sys_sem_new(sys_sem_t* sem,u8_t count)
err_t sys_sem_new(sys_sem_t* sem, u8_t count)
{
sem->valid = TRUE;
return sem_init(&sem->sem,count);
return sem_init(&sem->sem, count);
}
/* sys_sem_set_invalid(): this semapohore becomes invalid
@ -137,16 +141,11 @@ void sys_sem_signal(sys_sem_t* sem)
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
{
int err;
if (!timeout)
return sem_wait(&sem->sem);
while (timeout)
{
err = sem_trywait(&sem->sem);
if (err != -1)
return err;
udelay(1000);
timeout--;
}
err = sem_wait(&sem->sem, timeout);
if (!err)
return 0;
return SYS_ARCH_TIMEOUT;
}
@ -164,16 +163,11 @@ int sys_mbox_valid(sys_mbox_t * mbox)
*/
u32_t sys_arch_mbox_fetch(sys_mbox_t * mbox, void **msg, u32_t timeout)
{
if (!timeout)
return mailbox_ptr_fetch(&mbox->mailbox,msg);
int err;
while(timeout)
{
if (!mailbox_ptr_tryfetch(&mbox->mailbox,msg))
return 0;
udelay(1000);
timeout--;
}
err = mailbox_ptr_fetch(&mbox->mailbox, msg, timeout);
if (!err)
return 0;
return SYS_ARCH_TIMEOUT;
}
@ -192,13 +186,13 @@ void sys_mbox_free(sys_mbox_t* mbox)
*/
u32_t sys_arch_mbox_tryfetch(sys_mbox_t* mbox, void** msg)
{
return mailbox_ptr_tryfetch(&mbox->mailbox,msg);
mailbox_ptr_tryfetch(&mbox->mailbox, msg);
}
/* sys_mbox_new(): create a new mailbox with a minimum size of "size"
*
*/
err_t sys_mbox_new(sys_mbox_t* mbox,int size)
err_t sys_mbox_new(sys_mbox_t* mbox, int size)
{
mbox->valid = TRUE;
return mailbox_ptr_init(&mbox->mailbox);
@ -218,15 +212,19 @@ void sys_mbox_set_invalid(sys_mbox_t* mbox)
*/
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
{
return mailbox_ptr_post(&mbox->mailbox,msg);
int err;
err = mailbox_ptr_trypost(&mbox->mailbox, msg);
return err;
}
/* sys_mbox_post(): post new data to the mailbox
*
*/
void sys_mbox_post(sys_mbox_t* mbox,void* msg)
void sys_mbox_post(sys_mbox_t* mbox, void* msg)
{
mailbox_ptr_post(&mbox->mailbox,msg);
mailbox_ptr_post(&mbox->mailbox, msg);
}
/* sys_mutex_lock(): lock the given mutex
@ -235,7 +233,7 @@ void sys_mbox_post(sys_mbox_t* mbox,void* msg)
*/
void sys_mutex_lock(sys_mutex_t* mutex)
{
sem_wait(mutex);
sem_wait(mutex, 0);
}
/* sys_mutex_unlock(): unlock the given mutex
@ -251,23 +249,22 @@ void sys_mutex_unlock(sys_mutex_t* mutex)
*/
err_t sys_mutex_new(sys_mutex_t * mutex)
{
sem_init(mutex,1);
sem_init(mutex, 1);
return 0;
}
#if SYS_LIGHTWEIGHT_PROT
#if MAX_CORES > 1
static spinlock_irqsave_t lwprot_lock = SPINLOCK_IRQSAVE_INIT;
sys_prot_t sys_arch_protect(void)
{
spinlock_irqsave_lock(&lwprot_lock);
return 0;
spinlock_irqsave_lock(&lwprot_lock);
return 0;
}
void sys_arch_unprotect(sys_prot_t pval)
{
spinlock_irqsave_unlock(&lwprot_lock);
LWIP_UNUSED_ARG(pval);
spinlock_irqsave_unlock(&lwprot_lock);
}
#endif
#endif

View file

@ -81,5 +81,5 @@ typedef size_t mem_ptr_t;
#define LWIP_PLATFORM_ASSERT(x) do {kprintf("Assertion \"%s\" failed at line %d in %s\n", \
x, __LINE__, __FILE__); abort();} while(0)
#endif /* __ARCH_CC_H__ */

View file

@ -21,7 +21,7 @@ typedef struct
int valid;
} sys_mbox_t;
typedef tid_t* sys_thread_t;
typedef tid_t sys_thread_t;
#if SYS_LIGHTWEIGHT_PROT
#if MAX_CORES > 1
@ -43,4 +43,10 @@ static inline void sys_arch_unprotect(sys_prot_t pval)
#endif
#endif
/* define errno to determine error code */
#ifdef CONFIG_LWIP
#define ERRNO
#define errno per_core(current_task)->lwip_err
#endif
#endif /* __ARCH_SYS_ARCH_H__ */

View file

@ -117,5 +117,10 @@
#define NETIF_DEBUG LWIP_DBG_ON
#define TIMERS_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
// we need this feature to avoid memcpy operation between user- and kernel space
#define LWIP_TCPIP_CORE_LOCKING 1
//#define LWIP_TCPIP_THREAD_ALIVE() kputs("TCPIP thread is alive!\n")
#endif

View file

@ -16,13 +16,17 @@ TMP = $(TOPDIR)/tmp
OPT = --disable-shared --disable-multilib --enable-newlib-hw-fp
default: $(ARCH)
$(MAKE) -C examples depend
$(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C net depend
$(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C net
$(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C examples depend
$(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C examples
$(ARCH):
$(RM) $(TMP)
$(MKDIR) $(TMP)
$(CD) $(TMP); $(TOPDIR)/src/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) $(OPT) && make && make install
$(MKDIR) $(NEWLIB)/include/netinet
$(MKDIR) $(NEWLIB)/include/arpa
clean:
$(MAKE) -C examples clean

View file

@ -11,7 +11,7 @@ LDFLAGS =
default: all
all: hello tests jacobi
all: hello tests jacobi server client
jacobi: jacobi.o
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm
@ -31,8 +31,20 @@ hello: hello.o
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
chmod a-x $@.sym
server: server.o
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lsocket
$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
chmod a-x $@.sym
client: client.o
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lsocket
$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
chmod a-x $@.sym
clean:
$(RM) hello tests *.sym *.o *~
$(RM) hello tests server client *.sym *.o *~
depend:
$(CC_FOR_TARGET) -MM $(CFLAGS) *.c > Makefile.dep

57
newlib/examples/client.c Normal file
View file

@ -0,0 +1,57 @@
/* derived form http://www.cs.put.poznan.pl/csobaniec/examples/sockets/client-tcp-simple.c */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#undef errno
extern int errno;
#define MAX_BUF 100
int main(int argc, char* argv[])
{
int sockd;
int count;
struct sockaddr_in serv_name;
char buf[MAX_BUF];
int status;
if (argc < 3)
{
fprintf(stderr, "Usage: %s ip_address port_number\n", argv[0]);
exit(1);
}
/* create a socket */
sockd = socket(AF_INET, SOCK_STREAM, 0);
if (sockd == -1)
{
perror("Socket creation");
exit(1);
}
/* server address */
serv_name.sin_family = AF_INET;
inet_aton(argv[1], &serv_name.sin_addr);
serv_name.sin_port = htons(atoi(argv[2]));
/* connect to the server */
status = connect(sockd, (struct sockaddr*)&serv_name, sizeof(serv_name));
if (status == -1)
{
perror("Connection error");
exit(1);
}
count = read(sockd, buf, MAX_BUF);
write(1, buf, count);
close(sockd);
return 0;
}

72
newlib/examples/server.c Normal file
View file

@ -0,0 +1,72 @@
/* derived from http://www.cs.put.poznan.pl/csobaniec/examples/sockets/server-tcp-simple.c */
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#undef errno
extern int errno;
static char msg[] =" Hello from server!\n";
int main(int argc, char* argv[])
{
int sockd, sockd2;
unsigned int addrlen;
struct sockaddr_in my_name, peer_name;
int status;
/* create a socket */
sockd = socket(AF_INET, SOCK_STREAM, 0);
if (sockd == -1)
{
perror("Socket creation error");
exit(1);
}
if (argc < 2)
{
fprintf(stderr, "Usage: %s port_number\n", argv[0]);
exit(1);
}
/* server address */
my_name.sin_family = AF_INET;
my_name.sin_addr.s_addr = INADDR_ANY;
my_name.sin_port = htons(atoi(argv[1]));
status = bind(sockd, (struct sockaddr*)&my_name, sizeof(my_name));
if (status == -1)
{
perror("Binding error");
exit(1);
}
status = listen(sockd, 5);
if (status == -1)
{
perror("Listening error");
exit(1);
}
while(1)
{
/* wait for a connection */
addrlen = sizeof(peer_name);
sockd2 = accept(sockd, (struct sockaddr*)&peer_name, &addrlen);
if (sockd2 == -1)
{
perror("Wrong connection");
exit(1);
}
write(sockd2, msg, strlen(msg)+1);
close(sockd2);
}
return 0;
}

34
newlib/net/Makefile Normal file
View file

@ -0,0 +1,34 @@
ARCH = x86
NEWLIB = ../x86/i586-metalsvm-elf32
MAKE = make
STRIP_DEBUG = --strip-debug
KEEP_DEBUG = --only-keep-debug
LDFLAGS =
LIBNAME = libsocket.a
ARFLAGS = ruv
CP = cp
OBJS = accept.o bind.o closesocket.o connect.o listen.o recv.o send.o socket.o ip_addr.o
# other implicit rules
%.o : %.c
$(CC_FOR_TARGET) -c $(CFLAGS) -o $@ $<
default: all
all: $(LIBNAME)
$(LIBNAME): $(OBJS) socket.h
$(AR_FOR_TARGET) $(ARFLAGS) $@ $(OBJS)
$(CP) $@ $(NEWLIB)/lib
$(CP) socket.h $(NEWLIB)/include/sys
$(CP) in.h $(NEWLIB)/include/netinet
$(CP) inet.h $(NEWLIB)/include/arpa
clean:
$(RM) $(LIBNAME) *.o *~
depend:
$(CC_FOR_TARGET) -MM $(CFLAGS) *.c > Makefile.dep
-include Makefile.dep
# DO NOT DELETE

57
newlib/net/accept.c Normal file
View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
int
_DEFUN (accept, (s, addr, addrlen),
int s _AND void *addr _AND void *addrlen)
{
int ret;
ret = SYSCALL3(__NR_accept, s, addr, addrlen);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

57
newlib/net/bind.c Normal file
View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
int
_DEFUN (bind, (s, name, namelen),
int s _AND void *name _AND int namelen)
{
int ret;
ret = SYSCALL3(__NR_bind, s, name, namelen);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

57
newlib/net/closesocket.c Normal file
View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
int
_DEFUN (closesocket, (s),
int s)
{
int ret;
ret = SYSCALL1(__NR_closesocket, s);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

26
newlib/net/config.h Normal file
View file

@ -0,0 +1,26 @@
/* Name of package. */
#define PACKAGE libsocket
/* Version of package. */
#define VERSION 0.1
/* Missing syscall names */
#define MISSING_SYSCALL_NAMES 1
/* Using ELF format */
#define HAVE_ELF 1
/* Using GNU LD */
#define HAVE_GNU_LD 1
/* .previous directive allowed */
#define HAVE_ASM_PREVIOUS_DIRECTIVE 1
/* .pushsection/.popsection directives allowed */
#define HAVE_ASM_POPSECTION_DIRECTIVE 1
/* support for section attributes */
#define HAVE_SECTION_ATTRIBUTES 1
/* symbol prefix */
#define __SYMBOL_PREFIX ""

57
newlib/net/connect.c Normal file
View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
int
_DEFUN (connect, (s, name, namelen),
int s _AND void *name _AND int namelen)
{
int ret;
ret = SYSCALL3(__NR_connect, s, name, namelen);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

76
newlib/net/in.h Normal file
View file

@ -0,0 +1,76 @@
/*
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* The kernel of MetalSVM uses LwIP as lightweight TCP/IP stack.
* This header defines only a small wrapper to use LwIP functions
* from user space.
*/
#ifndef __NETINET_IN_H__
#define __NETINET_IN_H__
#include <stddef.h>
#include <sys/types.h>
#ifdef __cplusplus
{
#endif
struct in_addr {
uint32_t s_addr;
};
/** 255.255.255.255 */
#define IPADDR_NONE ((uint32_t)0xffffffffUL)
/** 127.0.0.1 */
#define IPADDR_LOOPBACK ((uint32_t)0x7f000001UL)
/** 0.0.0.0 */
#define IPADDR_ANY ((uint32_t)0x00000000UL)
/** 255.255.255.255 */
#define IPADDR_BROADCAST ((uint32_t)0xffffffffUL)
/** 255.255.255.255 */
#define INADDR_NONE IPADDR_NONE
/** 127.0.0.1 */
#define INADDR_LOOPBACK IPADDR_LOOPBACK
/** 0.0.0.0 */
#define INADDR_ANY IPADDR_ANY
/** 255.255.255.255 */
#define INADDR_BROADCAST IPADDR_BROADCAST
#ifdef __cplusplus
}
#endif
#endif /* __NETINET_IN_H__ */

109
newlib/net/inet.h Normal file
View file

@ -0,0 +1,109 @@
/*
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* The kernel of MetalSVM uses LwIP as lightweight TCP/IP stack.
* This header defines only a small wrapper to use LwIP functions
* from user space.
*/
#ifndef __ARPA_INET_H__
#define __ARPA_INET_H__
#include <stddef.h>
#include <sys/types.h>
#ifdef __cplusplus
{
#endif
/*
* This is the aligned version of ip_addr_t,
* used as local variable, on the stack, etc.
*/
struct ip_addr {
uint32_t addr;
};
#ifndef LITTLE_ENDIAN
// Convert an uint16_t from host- to network byte order.
static inline uint16_t htons(uint16_t n)
{
return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
}
// Convert an uint16_t from network- to host byte order.
static inline uint16_t ntohs(uint16_t n)
{
return htons(n);
}
// Convert an uint32_t from host- to network byte order.
static inline uint32_t htonl(uint32_t n)
{
return ((n & 0xff) << 24) | ((n & 0xff00) << 8) | ((n & 0xff0000UL) >> 8) |
((n & 0xff000000UL) >> 24);
}
// Convert an uint32_t from network- to host byte order.
static inline uint32_t ntohl(uint32_t n)
{
return htonl(n);
}
#else
#error currently not supported!!!
#endif
/** ip_addr_t uses a struct for convenience only, so that the same defines can
* operate both on ip_addr_t as well as on ip_addr_p_t. */
typedef struct ip_addr ip_addr_t;
//typedef struct ip_addr_packed ip_addr_p_t;
uint32_t ipaddr_addr(const char *cp);
int ipaddr_aton(const char *cp, ip_addr_t *addr);
/** returns ptr to static buffer; not reentrant! */
char *ipaddr_ntoa(const ip_addr_t *addr);
char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen);
/* directly map this to the lwip internal functions */
#define inet_addr(cp) ipaddr_addr(cp)
#define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr)
#define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr))
#define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen)
#ifdef __cplusplus
}
#endif
#endif /* __NETINET_IN_H__ */

336
newlib/net/ip_addr.c Normal file
View file

@ -0,0 +1,336 @@
/**
* @file
* This is the IPv4 address tools implementation.
*
*/
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
/*
* LwIP backports of helper function for user-space applications
*/
#include "inet.h"
#include <stdio.h>
/* Define generic types used in lwIP */
typedef uint8_t u8_t;
typedef int8_t s8_t;
typedef uint16_t u16_t;
typedef int16_t s16_t;
typedef uint32_t u32_t;
typedef int32_t s32_t;
#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \
fprintf(stderr, message); } while(0)
/** IPv4 only: set the IP address given as an u32_t */
#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32))
/** IPv4 only: get the IP address as an u32_t */
#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr)
#if 0
#include "lwip/opt.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */
const ip_addr_t ip_addr_any = { IPADDR_ANY };
const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST };
/**
* Determine if an address is a broadcast address on a network interface
*
* @param addr address to be checked
* @param netif the network interface against which the address is checked
* @return returns non-zero if the address is a broadcast address
*/
u8_t
ip4_addr_isbroadcast(u32_t addr, const struct netif *netif)
{
ip_addr_t ipaddr;
ip4_addr_set_u32(&ipaddr, addr);
/* all ones (broadcast) or all zeroes (old skool broadcast) */
if ((~addr == IPADDR_ANY) ||
(addr == IPADDR_ANY)) {
return 1;
/* no broadcast support on this network interface? */
} else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0) {
/* the given address cannot be a broadcast address
* nor can we check against any broadcast addresses */
return 0;
/* address matches network interface address exactly? => no broadcast */
} else if (addr == ip4_addr_get_u32(&netif->ip_addr)) {
return 0;
/* on the same (sub) network... */
} else if (ip_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask))
/* ...and host identifier bits are all ones? =>... */
&& ((addr & ~ip4_addr_get_u32(&netif->netmask)) ==
(IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask)))) {
/* => network broadcast address */
return 1;
} else {
return 0;
}
}
/** Checks if a netmask is valid (starting with ones, then only zeros)
*
* @param netmask the IPv4 netmask to check (in network byte order!)
* @return 1 if the netmask is valid, 0 if it is not
*/
u8_t
ip4_addr_netmask_valid(u32_t netmask)
{
u32_t mask;
u32_t nm_hostorder = lwip_htonl(netmask);
/* first, check for the first zero */
for (mask = 1UL << 31 ; mask != 0; mask >>= 1) {
if ((nm_hostorder & mask) == 0) {
break;
}
}
/* then check that there is no one */
for (; mask != 0; mask >>= 1) {
if ((nm_hostorder & mask) != 0) {
/* there is a one after the first zero -> invalid */
return 0;
}
}
/* no one after the first zero -> valid */
return 1;
}
/* Here for now until needed in other places in lwIP */
#ifndef isprint
#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up)
#define isprint(c) in_range(c, 0x20, 0x7f)
#define isdigit(c) in_range(c, '0', '9')
#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
#define islower(c) in_range(c, 'a', 'z')
#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
#endif
/**
* Ascii internet address interpretation routine.
* The value returned is in network order.
*
* @param cp IP address in ascii represenation (e.g. "127.0.0.1")
* @return ip address in network order
*/
u32_t
ipaddr_addr(const char *cp)
{
ip_addr_t val;
if (ipaddr_aton(cp, &val)) {
return ip4_addr_get_u32(&val);
}
return (IPADDR_NONE);
}
#endif
/**
* Check whether "cp" is a valid ascii representation
* of an Internet address and convert to a binary address.
* Returns 1 if the address is valid, 0 if not.
* This replaces inet_addr, the return value from which
* cannot distinguish between failure and a local broadcast address.
*
* @param cp IP address in ascii represenation (e.g. "127.0.0.1")
* @param addr pointer to which to save the ip address in network order
* @return 1 if cp could be converted to addr, 0 on failure
*/
int
ipaddr_aton(const char *cp, ip_addr_t *addr)
{
u32_t val;
u8_t base;
char c;
u32_t parts[4];
u32_t *pp = parts;
c = *cp;
for (;;) {
/*
* Collect number up to ``.''.
* Values are specified as for C:
* 0x=hex, 0=octal, 1-9=decimal.
*/
if (!isdigit(c))
return (0);
val = 0;
base = 10;
if (c == '0') {
c = *++cp;
if (c == 'x' || c == 'X') {
base = 16;
c = *++cp;
} else
base = 8;
}
for (;;) {
if (isdigit(c)) {
val = (val * base) + (int)(c - '0');
c = *++cp;
} else if (base == 16 && isxdigit(c)) {
val = (val << 4) | (int)(c + 10 - (islower(c) ? 'a' : 'A'));
c = *++cp;
} else
break;
}
if (c == '.') {
/*
* Internet format:
* a.b.c.d
* a.b.c (with c treated as 16 bits)
* a.b (with b treated as 24 bits)
*/
if (pp >= parts + 3) {
return (0);
}
*pp++ = val;
c = *++cp;
} else
break;
}
/*
* Check for trailing characters.
*/
if (c != '\0' && !isspace(c)) {
return (0);
}
/*
* Concoct the address according to
* the number of parts specified.
*/
switch (pp - parts + 1) {
case 0:
return (0); /* initial nondigit */
case 1: /* a -- 32 bits */
break;
case 2: /* a.b -- 8.24 bits */
if (val > 0xffffffUL) {
return (0);
}
val |= parts[0] << 24;
break;
case 3: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff) {
return (0);
}
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 4: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff) {
return (0);
}
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
default:
LWIP_ASSERT("unhandled", 0);
break;
}
if (addr) {
ip4_addr_set_u32(addr, htonl(val));
}
return (1);
}
/**
* Convert numeric IP address into decimal dotted ASCII representation.
* returns ptr to static buffer; not reentrant!
*
* @param addr ip address in network order to convert
* @return pointer to a global static (!) buffer that holds the ASCII
* represenation of addr
*/
char *
ipaddr_ntoa(const ip_addr_t *addr)
{
static char str[16];
return ipaddr_ntoa_r(addr, str, 16);
}
/**
* Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used.
*
* @param addr ip address in network order to convert
* @param buf target buffer where the string is stored
* @param buflen length of buf
* @return either pointer to buf which now holds the ASCII
* representation of addr or NULL if buf was too small
*/
char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen)
{
u32_t s_addr;
char inv[3];
char *rp;
u8_t *ap;
u8_t rem;
u8_t n;
u8_t i;
int len = 0;
s_addr = ip4_addr_get_u32(addr);
rp = buf;
ap = (u8_t *)&s_addr;
for(n = 0; n < 4; n++) {
i = 0;
do {
rem = *ap % (u8_t)10;
*ap /= (u8_t)10;
inv[i++] = '0' + rem;
} while(*ap);
while(i--) {
if (len++ >= buflen) {
return NULL;
}
*rp++ = inv[i];
}
if (len++ >= buflen) {
return NULL;
}
*rp++ = '.';
ap++;
}
*--rp = 0;
return buf;
}

57
newlib/net/listen.c Normal file
View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
int
_DEFUN (listen, (s, backlog),
int s _AND int backlog)
{
int ret;
ret = SYSCALL2(__NR_listen, s, backlog);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

57
newlib/net/recv.c Normal file
View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
int
_DEFUN (recv, (s, data, size,flags),
int s _AND void *data _AND int size _AND int flags)
{
int ret;
ret = SYSCALL4(__NR_recv, s, data, size, flags);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

57
newlib/net/send.c Normal file
View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
int
_DEFUN (send, (s, data, size,flags),
int s _AND void *data _AND int size _AND int flags)
{
int ret;
ret = SYSCALL4(__NR_send, s, data, size, flags);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

57
newlib/net/socket.c Normal file
View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
int
_DEFUN (socket, (domain, type, protocol),
int domain _AND int type _AND int protocol)
{
int ret;
ret = SYSCALL3(__NR_socket, domain, type, protocol);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

323
newlib/net/socket.h Normal file
View file

@ -0,0 +1,323 @@
/*
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* The kernel of MetalSVM uses LwIP as lightweight TCP/IP stack.
* This header defines only a small wrapper to use LwIP functions
* from user space.
*/
#ifndef __SOCKET_H__
#define __SOCKET_H__
#include <stddef.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef __cplusplus
{
#endif
struct sockaddr_in {
uint8_t sin_len;
uint8_t sin_family;
uint16_t sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
struct sockaddr {
uint8_t sa_len;
uint8_t sa_family;
char sa_data[14];
};
#ifndef socklen_t
# define socklen_t uint32_t
#endif
/* Socket protocol types (TCP/UDP/RAW) */
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define SOCK_RAW 3
/*
* Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
*/
#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
#define SO_REUSEADDR 0x0004 /* Allow local address reuse */
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */
#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
#define SO_LINGER 0x0080 /* linger on close if data present */
#define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */
#define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */
#define SO_DONTLINGER ((int)(~SO_LINGER))
/*
* Additional options, not kept in so_options.
*/
#define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */
#define SO_RCVBUF 0x1002 /* receive buffer size */
#define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */
#define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */
#define SO_SNDTIMEO 0x1005 /* Unimplemented: send timeout */
#define SO_RCVTIMEO 0x1006 /* receive timeout */
#define SO_ERROR 0x1007 /* get error status and clear */
#define SO_TYPE 0x1008 /* get socket type */
#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
#define SO_NO_CHECK 0x100a /* don't create UDP checksum */
/*
* Structure used for manipulating linger option.
*/
struct linger {
int l_onoff; /* option on/off */
int l_linger; /* linger time */
};
/*
* Level number for (get/set)sockopt() to apply to socket itself.
*/
#define SOL_SOCKET 0xfff /* options for socket level */
#define AF_UNSPEC 0
#define AF_INET 2
#define PF_INET AF_INET
#define PF_UNSPEC AF_UNSPEC
#define IPPROTO_IP 0
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
#define IPPROTO_UDPLITE 136
/* Flags we can use with send and recv. */
#define MSG_PEEK 0x01 /* Peeks at an incoming message */
#define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */
#define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */
#define MSG_MORE 0x10 /* Sender will send more */
/*
* Options for level IPPROTO_IP
*/
#define IP_TOS 1
#define IP_TTL 2
/*
* Options for level IPPROTO_TCP
*/
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
/*
* Options for level IPPROTO_UDPLITE
*/
#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
/*
* Options and types for UDP multicast traffic handling
*/
#define IP_ADD_MEMBERSHIP 3
#define IP_DROP_MEMBERSHIP 4
#define IP_MULTICAST_TTL 5
#define IP_MULTICAST_IF 6
#define IP_MULTICAST_LOOP 7
typedef struct ip_mreq {
struct in_addr imr_multiaddr; /* IP multicast address of group */
struct in_addr imr_interface; /* local IP address of interface */
} ip_mreq;
/*
* The Type of Service provides an indication of the abstract
* parameters of the quality of service desired. These parameters are
* to be used to guide the selection of the actual service parameters
* when transmitting a datagram through a particular network. Several
* networks offer service precedence, which somehow treats high
* precedence traffic as more important than other traffic (generally
* by accepting only traffic above a certain precedence at time of high
* load). The major choice is a three way tradeoff between low-delay,
* high-reliability, and high-throughput.
* The use of the Delay, Throughput, and Reliability indications may
* increase the cost (in some sense) of the service. In many networks
* better performance for one of these parameters is coupled with worse
* performance on another. Except for very unusual cases at most two
* of these three indications should be set.
*/
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
#define IPTOS_LOWDELAY 0x10
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_RELIABILITY 0x04
#define IPTOS_LOWCOST 0x02
#define IPTOS_MINCOST IPTOS_LOWCOST
/*
* The Network Control precedence designation is intended to be used
* within a network only. The actual use and control of that
* designation is up to each network. The Internetwork Control
* designation is intended for use by gateway control originators only.
* If the actual use of these precedence designations is of concern to
* a particular network, it is the responsibility of that network to
* control the access to, and use of, those precedence designations.
*/
#define IPTOS_PREC_MASK 0xe0
#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/*
* Commands for ioctlsocket(), taken from the BSD file fcntl.h.
* lwip_ioctl only supports FIONREAD and FIONBIO, for now
*
* Ioctl's have the command encoded in the lower word,
* and the size of any in or out parameters in the upper
* word. The high 2 bits of the upper word are used
* to encode the in/out status of the parameter; for now
* we restrict parameters to at most 128 bytes.
*/
#if !defined(FIONREAD) || !defined(FIONBIO)
#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */
#define IOC_VOID 0x20000000UL /* no parameters */
#define IOC_OUT 0x40000000UL /* copy out parameters */
#define IOC_IN 0x80000000UL /* copy in parameters */
#define IOC_INOUT (IOC_IN|IOC_OUT)
/* 0x20000000 distinguishes new &
old ioctl's */
#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
#endif /* !defined(FIONREAD) || !defined(FIONBIO) */
#ifndef FIONREAD
#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */
#endif
#ifndef FIONBIO
#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
#endif
/* Socket I/O Controls: unimplemented */
#ifndef SIOCSHIWAT
#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */
#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */
#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */
#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */
#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
#endif
/* commands for fnctl */
#ifndef F_GETFL
#define F_GETFL 3
#endif
#ifndef F_SETFL
#define F_SETFL 4
#endif
/* File status flags and file access modes for fnctl,
these are bits in an int. */
#ifndef O_NONBLOCK
#define O_NONBLOCK 1 /* nonblocking I/O */
#endif
#ifndef O_NDELAY
#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */
#endif
#ifndef SHUT_RD
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
#endif
/* FD_SET used for lwip_select */
#ifndef FD_SET
#undef FD_SETSIZE
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
#define FD_SETSIZE MEMP_NUM_NETCONN
#define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7)))
#define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
#define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7)))
#define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p)))
typedef struct fd_set {
unsigned char fd_bits [(FD_SETSIZE+7)/8];
} fd_set;
#endif /* FD_SET */
int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int bind(int s, const struct sockaddr *name, socklen_t namelen);
int getpeername (int s, struct sockaddr *name, socklen_t *namelen);
int getsockname (int s, struct sockaddr *name, socklen_t *namelen);
int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
int connect(int s, const struct sockaddr *name, socklen_t namelen);
int listen(int s, int backlog);
int recv(int s, void *mem, size_t len, int flags);
int recvfrom(int s, void *mem, size_t len, int flags,
struct sockaddr *from, socklen_t *fromlen);
int send(int s, const void *dataptr, size_t size, int flags);
int sendto(int s, const void *dataptr, size_t size, int flags,
const struct sockaddr *to, socklen_t tolen);
int socket(int domain, int type, int protocol);
//int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
// struct timeval *timeout);
//int ioctl(int s, long cmd, void *argp);
//int fcntl(int s, int cmd, int val);
#ifdef __cplusplus
}
#endif
#endif /* __SOCKET_H__ */

102
newlib/net/syscall.h Normal file
View file

@ -0,0 +1,102 @@
/*
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/
#ifndef __SYSCALL_H__
#define __SYSCALL_H__
#ifdef __cplusplus
extern "C" {
#endif
#define __NR_exit 0
#define __NR_write 1
#define __NR_open 2
#define __NR_close 3
#define __NR_read 4
#define __NR_lseek 6
#define __NR_unlink 7
#define __NR_getpid 8
#define __NR_kill 9
#define __NR_fstat 10
#define __NR_sbrk 11
#define __NR_fork 12
#define __NR_wait 13
#define __NR_execve 14
#define __NR_times 15
#define __NR_accept 16
#define __NR_bind 17
#define __NR_closesocket 18
#define __NR_connect 19
#define __NR_listen 20
#define __NR_recv 21
#define __NR_send 22
#define __NR_socket 23
#define _STR(token) #token
#define _SYSCALLSTR(x) "int $" _STR(x) " "
#define INT_SYSCALL 0x80
inline static long
syscall(int nr, unsigned long arg0, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4)
{
long res;
asm volatile (_SYSCALLSTR(INT_SYSCALL)
: "=a" (res)
: "0" (nr), "b" (arg0), "c" (arg1), "d" (arg2), "S" (arg3), "D" (arg4)
: "memory", "cc");
return res;
}
#define SYSCALL0(NR) \
syscall(NR, 0, 0, 0, 0, 0)
#define SYSCALL1(NR, ARG1) \
syscall(NR, (unsigned long)ARG1, 0, 0, 0, 0)
#define SYSCALL2(NR, ARG1, ARG2) \
syscall(NR, (unsigned long)ARG1, (unsigned long)ARG2, 0, 0, 0)
#define SYSCALL3(NR, ARG1, ARG2, ARG3) \
syscall(NR, (unsigned long)ARG1, (unsigned long)ARG2, (unsigned long)ARG3, 0, 0)
#define SYSCALL4(NR, ARG1, ARG2, ARG3, ARG4) \
syscall(NR, (unsigned long)ARG1, (unsigned long)ARG2, (unsigned long)ARG3, (unsigned long) ARG4, 0)
#define SYSCALL5(NR, ARG1, ARG2, ARG3, ARG4) \
syscall(NR, (unsigned long)ARG1, (unsigned long)ARG2, (unsigned long)ARG3, (unsigned long) ARG4, (unsigned long) ARG5)
#ifdef __cplusplus
}
#endif
#endif

44
newlib/net/warning.h Normal file
View file

@ -0,0 +1,44 @@
#ifndef __WARNING_H__
#define __WARNING_H__
#ifdef HAVE_GNU_LD
# ifdef HAVE_ELF
/* We want the .gnu.warning.SYMBOL section to be unallocated. */
# ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
# define __make_section_unallocated(section_string) \
asm(".section " section_string "\n .previous");
# elif defined (HAVE_ASM_POPSECTION_DIRECTIVE)
# define __make_section_unallocated(section_string) \
asm(".pushsection " section_string "\n .popsection");
# else
# define __make_section_unallocated(section_string)
# endif
# ifdef HAVE_SECTION_ATTRIBUTES
# define link_warning(symbol, msg) \
static const char __evoke_link_warning_##symbol[] \
__attribute__ ((section (".gnu.warning." __SYMBOL_PREFIX #symbol), \
__used__)) = msg;
# else
# define link_warning(symbol, msg)
# endif
#else /* !ELF */
# define link_warning(symbol, msg) \
asm(".stabs \"" msg "\",30,0,0,0\n" \
".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
# endif
#else /* !GNULD */
/* We will never be heard; they will all die horribly. */
# define link_warning(symbol, msg)
#endif
/* A canned warning for sysdeps/stub functions.
The GNU linker prepends a "warning: " string. */
#define stub_warning(name) \
link_warning (name, \
#name " is not implemented and will always fail")
#endif /* __WARNING_H__ */

View file

@ -1,20 +1,36 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
* This file is part of MetalSVM.
*/
#include "config.h"

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,20 +1,35 @@
;
; Copyright 2010 Stefan Lankes, Chair for Operating Systems,
; RWTH Aachen University
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; This file is part of MetalSVM.
; Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
; RWTH Aachen University
;
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; 1. Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; 2. Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
; 3. All advertising materials mentioning features or use of this software
; must display the following acknowledgement:
; This product includes software developed by the Chair for Operating Systems,
; RWTH Aachen University.
; 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
; nor the names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
; This file is part of MetalSVM.
[BITS 32]
SECTION .text

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,20 +1,36 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Standard x86 syscalls for user programs running under MetalSVM
* This file is part of MetalSVM.
*/
#ifndef __SYSCALL_H__
@ -39,6 +55,14 @@ extern "C" {
#define __NR_wait 13
#define __NR_execve 14
#define __NR_times 15
#define __NR_accept 16
#define __NR_bind 17
#define __NR_closesocket 18
#define __NR_connect 19
#define __NR_listen 20
#define __NR_recv 21
#define __NR_send 22
#define __NR_socket 23
#define _STR(token) #token
#define _SYSCALLSTR(x) "int $" _STR(x) " "

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -1,18 +1,34 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
* Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Chair for Operating Systems,
* RWTH Aachen University.
* 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of MetalSVM.
*/

View file

@ -9,3 +9,13 @@ if [ $SIZE -ne 0 ]; then
else
echo not patching $NAME
fi;
NAME=initrd.img
SIZE=`ls -ld "$NAME" | awk '{print $5 % 64}'`
if [ $SIZE -ne 0 ]; then
echo "$NAME: patching $SIZE Zero-Bytes"
dd if=/dev/zero of=zero.bin bs=1 count=$SIZE
cat zero.bin >> $NAME
else
echo not patching $NAME
fi;