From 27e1aee7ef42cf280dacf77e7e8b6e1ebc3b79a0 Mon Sep 17 00:00:00 2001 From: stefan Date: Tue, 17 Aug 2010 10:25:50 +0000 Subject: [PATCH] - add missing files - update of the configure example git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@98 315a16e6-25f9-4109-90ae-ca3045a26c18 --- include/metalsvm/config.h.example | 8 ++++ include/stdarg.h | 35 +++++++++++++++ libgloss/crt0.asm | 75 +++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 include/stdarg.h create mode 100644 libgloss/crt0.asm diff --git a/include/metalsvm/config.h.example b/include/metalsvm/config.h.example index 50ea4720..6c0e0501 100644 --- a/include/metalsvm/config.h.example +++ b/include/metalsvm/config.h.example @@ -62,6 +62,8 @@ extern "C" { #define HAVE_ARCH_MEMSET #define HAVE_ARCH_MEMCPY #define HAVE_ARCH_STRLEN +#define HAVE_ARCH_STRCPY +#define HAVE_ARCH_STRNCPY typedef unsigned long long uint64_t; typedef long long int64_t; @@ -71,6 +73,12 @@ typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned char uint8_t; typedef char int8_t; +typedef unsigned short wchar_t; + +#ifndef _WINT_T +#define _WINT_T +typedef unsigned int wint_t; +#endif #ifdef __cplusplus } diff --git a/include/stdarg.h b/include/stdarg.h new file mode 100644 index 00000000..a4089dad --- /dev/null +++ b/include/stdarg.h @@ -0,0 +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. + */ + +#ifndef __ANSI_STDARG_H__ +#define __ANSI_STDARG_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define __VALIST va_list + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libgloss/crt0.asm b/libgloss/crt0.asm new file mode 100644 index 00000000..fd6d381c --- /dev/null +++ b/libgloss/crt0.asm @@ -0,0 +1,75 @@ +; +; 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. + +[BITS 32] +SECTION .data + cmdline DB "cmdline", 0 + argv DD 0, 0 + +SECTION .text +global _start +extern main +extern __do_global_dtors +extern __do_global_ctors +extern hardware_init_hook +extern software_init_hook +extern atexit +extern exit +_start: + ; call init hooks, if any exists + lea eax, [hardware_init_hook] + cmp eax, 0 + je L1 + call eax +L1: + lea eax, [software_init_hook] + cmp eax, 0 + je L2 + call eax +L2: + ; register a function to be called at normal process termination + push __do_global_dtors + call atexit + pop eax + + ; call init function + call __do_global_ctors + + ; build argc/argv pair and then push + ; them onto the stack... + mov [argv+0], DWORD cmdline + mov eax, [esp+4] + mov [argv+4], eax + push argv + push 2 + + ; call the user's function + call main + + ; remove argc/argv pair + add esp, 8 + + ; call exit from the C library so atexit gets called, and the + ; C++ destructors get run. This calls our exit routine below + ; when it's done. + ; call "exit" + push eax + call exit + + ; endless loop + jmp $