
git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@2 315a16e6-25f9-4109-90ae-ca3045a26c18
76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
/*
|
|
* 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 __ARCH_TASKS__
|
|
#define __ARCH_TASKS__
|
|
|
|
#include <metalsvm/stddef.h>
|
|
#include <metalsvm/tasks_types.h>
|
|
|
|
void NORETURN leave_task(void);
|
|
|
|
inline static int create_default_frame(task_t* task, entry_point_t ep, void* arg)
|
|
{
|
|
unsigned int* top = (unsigned int*) task->top;
|
|
unsigned int* esp;
|
|
unsigned int* ebp;
|
|
|
|
*top = 0xDEADBEAF; /* dead-end */
|
|
ebp = top;
|
|
top--;
|
|
*top = (unsigned int) arg; /* argument of the function ep */
|
|
top--;
|
|
*top = (unsigned int) leave_task; /* exit function */
|
|
top--;
|
|
*top = (unsigned int) ep; /* entry point */
|
|
top--;
|
|
*top = 0x202; /* EFLAGS */
|
|
esp = top;
|
|
top--;
|
|
*top = 0x00; /* EAX */
|
|
top--;
|
|
*top = 0x00; /* ECX */
|
|
top--;
|
|
*top = 0x00; /* EDX */
|
|
top--;
|
|
*top = 0x00; /* EBX */
|
|
top--;
|
|
*top = (unsigned int) esp; /* ESP */
|
|
top--;
|
|
*top = (unsigned int) ebp; /* EBP */
|
|
top --;
|
|
*top = 0x00; /* ESI */
|
|
top --;
|
|
*top = 0x00; /* EDI */
|
|
top --;
|
|
*top = 0x10; /* DS */
|
|
top--;
|
|
*top = 0x10; /* ES */
|
|
top--;
|
|
*top = 0x10; /* FS */
|
|
top--;
|
|
*top = 0x10; /* GS */
|
|
|
|
task->top = (unsigned char*) top;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#endif
|