2010-07-31 15:53:30 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-04-04 18:12:08 +02:00
|
|
|
/**
|
|
|
|
* @author Stefan Lankes
|
|
|
|
* @file arch/x86/include/asm/stddef.h
|
|
|
|
* @brief Standard datatypes
|
|
|
|
*
|
|
|
|
* This file contains typedefs for standard datatypes for numerical and character values.
|
|
|
|
*/
|
|
|
|
|
2010-07-31 15:53:30 +00:00
|
|
|
#ifndef __ARCH_STDDEF_H__
|
|
|
|
#define __ARCH_STDDEF_H__
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-05-24 10:49:45 +02:00
|
|
|
#if __SIZEOF_POINTER__ == 4
|
|
|
|
#define CONFIG_X86_32
|
2011-04-04 18:12:08 +02:00
|
|
|
/// A popular type for addresses
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef unsigned long size_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Pointer differences
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef long ptrdiff_t;
|
2010-08-22 10:08:38 +00:00
|
|
|
#ifdef __KERNEL__
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef long ssize_t;
|
|
|
|
typedef long off_t;
|
|
|
|
#endif
|
2012-05-24 10:49:45 +02:00
|
|
|
#elif __SIZEOF_POINTER__ == 8
|
|
|
|
#define CONFIG_X86_64
|
|
|
|
// A popular type for addresses
|
|
|
|
typedef unsigned long long size_t;
|
|
|
|
/// Pointer differences
|
|
|
|
typedef long long ptrdiff_t;
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
typedef long long ssize_t;
|
|
|
|
typedef long long off_t;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#error unsupported architecture
|
|
|
|
#endif
|
2010-08-22 09:56:02 +00:00
|
|
|
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Unsigned 64 bit integer
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef unsigned long long uint64_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Signed 64 bit integer
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef long long int64_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Unsigned 32 bit integer
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef unsigned int uint32_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Signed 32 bit integer
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef int int32_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Unsigned 16 bit integer
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef unsigned short uint16_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Signed 16 bit integer
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef short int16_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Unsigned 8 bit integer (/char)
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef unsigned char uint8_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// Signed 8 bit integer (/char)
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef char int8_t;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// 16 bit wide char type
|
2010-08-22 09:56:02 +00:00
|
|
|
typedef unsigned short wchar_t;
|
|
|
|
|
|
|
|
#ifndef _WINT_T
|
|
|
|
#define _WINT_T
|
|
|
|
typedef unsigned int wint_t;
|
|
|
|
#endif
|
2010-07-31 15:53:30 +00:00
|
|
|
|
2011-04-04 18:12:08 +02:00
|
|
|
/** @brief This defines what the stack looks like after an ISR was called.
|
|
|
|
*
|
|
|
|
* All the interrupt handler routines use this type for their only parameter.
|
2012-08-24 14:42:37 +02:00
|
|
|
* Note: Our kernel doesn't use the GS and FS registers.
|
2011-04-04 18:12:08 +02:00
|
|
|
*/
|
2010-08-09 11:47:51 +00:00
|
|
|
struct state {
|
2012-06-10 08:05:24 +02:00
|
|
|
#ifdef CONFIG_X86_32
|
2012-08-24 14:42:37 +02:00
|
|
|
// ds register
|
|
|
|
uint32_t ds;
|
|
|
|
// es register
|
|
|
|
uint32_t es;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// EDI register
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t edi;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// ESI register
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t esi;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// EBP register
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t ebp;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// ESP register
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t esp;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// EBX register
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t ebx;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// EDX register
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t edx;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// ECX register
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t ecx;
|
2011-04-04 18:12:08 +02:00
|
|
|
/// EAX register
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t eax; /* pushed by 'pusha' */
|
2011-04-04 18:12:08 +02:00
|
|
|
|
|
|
|
/// Interrupt number
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t int_no;
|
2011-07-19 09:10:12 +02:00
|
|
|
|
|
|
|
// pushed by the processor automatically
|
2012-06-10 08:05:24 +02:00
|
|
|
uint32_t error;
|
|
|
|
uint32_t eip;
|
|
|
|
uint32_t cs;
|
|
|
|
uint32_t eflags;
|
|
|
|
uint32_t useresp;
|
|
|
|
uint32_t ss;
|
|
|
|
#elif defined(CONFIG_X86_64)
|
|
|
|
/// R15 register
|
|
|
|
uint64_t r15;
|
|
|
|
/// R14 register
|
|
|
|
uint64_t r14;
|
|
|
|
/// R13 register
|
|
|
|
uint64_t r13;
|
|
|
|
/// R12 register
|
|
|
|
uint64_t r12;
|
|
|
|
/// R11 register
|
|
|
|
uint64_t r11;
|
|
|
|
/// R10 register
|
|
|
|
uint64_t r10;
|
|
|
|
/// R9 register
|
|
|
|
uint64_t r9;
|
|
|
|
/// R8 register
|
|
|
|
uint64_t r8;
|
|
|
|
/// RDI register
|
|
|
|
uint64_t rdi;
|
|
|
|
/// RSI register
|
|
|
|
uint64_t rsi;
|
|
|
|
/// RBP register
|
|
|
|
uint64_t rbp;
|
|
|
|
/// (pseudo) RSP register
|
|
|
|
uint64_t rsp;
|
|
|
|
/// RBX register
|
|
|
|
uint64_t rbx;
|
|
|
|
/// RDX register
|
|
|
|
uint64_t rdx;
|
|
|
|
/// RCX register
|
|
|
|
uint64_t rcx;
|
|
|
|
/// RAX register
|
|
|
|
uint64_t rax;
|
|
|
|
|
|
|
|
/// Interrupt number
|
|
|
|
uint64_t int_no;
|
|
|
|
|
|
|
|
// pushed by the processor automatically
|
|
|
|
uint64_t error;
|
|
|
|
uint64_t rip;
|
|
|
|
uint64_t cs;
|
|
|
|
uint64_t rflags;
|
|
|
|
uint64_t userrsp;
|
|
|
|
uint64_t ss;
|
|
|
|
#endif
|
2010-07-31 15:53:30 +00:00
|
|
|
};
|
|
|
|
|
2011-07-20 08:24:24 +02:00
|
|
|
uint32_t apic_cpu_id(void);
|
|
|
|
|
|
|
|
#define smp_id apic_cpu_id
|
|
|
|
|
2010-07-31 15:53:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|