diff options
author | fishsoupisgood <github@madingley.org> | 2019-04-29 01:17:54 +0100 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2019-05-27 03:43:43 +0100 |
commit | 3f2546b2ef55b661fd8dd69682b38992225e86f6 (patch) | |
tree | 65ca85f13617aee1dce474596800950f266a456c /roms/SLOF/clients/net-snk/kernel/init.c | |
download | qemu-master.tar.gz qemu-master.tar.bz2 qemu-master.zip |
Diffstat (limited to 'roms/SLOF/clients/net-snk/kernel/init.c')
-rw-r--r-- | roms/SLOF/clients/net-snk/kernel/init.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/roms/SLOF/clients/net-snk/kernel/init.c b/roms/SLOF/clients/net-snk/kernel/init.c new file mode 100644 index 00000000..1376b647 --- /dev/null +++ b/roms/SLOF/clients/net-snk/kernel/init.c @@ -0,0 +1,67 @@ +/****************************************************************************** + * Copyright (c) 2004, 2008 IBM Corporation + * All rights reserved. + * This program and the accompanying materials + * are made available under the terms of the BSD License + * which accompanies this distribution, and is available at + * http://www.opensource.org/licenses/bsd-license.php + * + * Contributors: + * IBM Corporation - initial implementation + *****************************************************************************/ + +#include <stdint.h> +#include <string.h> +#include <stdlib.h> /* malloc */ +#include <of.h> +#include <pci.h> +#include <kernel.h> +#include <cpu.h> +#include <fileio.h> + +/* Application entry point .*/ +extern int _start(unsigned char *arg_string, long len); +extern int main(int, char**); +int _start_kernel(unsigned long p0, unsigned long p1); +void * malloc_aligned(size_t size, int align); + +unsigned long exception_stack_frame; + +snk_fileio_t fd_array[FILEIO_MAX]; + +extern uint64_t tb_freq; + +extern char __client_start; +extern char __client_end; + +void * malloc_aligned(size_t size, int align) +{ + unsigned long p = (unsigned long) malloc(size + align - 1); + p = p + align - 1; + p = p & ~(align - 1); + + return (void *) p; +} + +int _start_kernel(unsigned long p0, unsigned long p1) +{ + int rc; + unsigned int timebase; + + /* initialize all file descriptor by marking them as empty */ + for(rc=0; rc<FILEIO_MAX; ++rc) + fd_array[rc].type = FILEIO_TYPE_EMPTY; + + /* this is step is e.g. resposible to initialize file descriptor 0 and 1 for STDIO */ + rc = of_glue_init(&timebase, (size_t)(unsigned long)&__client_start, + (size_t)(unsigned long)&__client_end - (size_t)(unsigned long)&__client_start); + if(rc < 0) + return -1; + + tb_freq = (uint64_t) timebase; + rc = _start((unsigned char *) p0, p1); + + of_glue_release(); + return rc; +} + |