diff options
Diffstat (limited to 'nuttx/arch/x86/include/i486')
-rwxr-xr-x | nuttx/arch/x86/include/i486/arch.h | 108 | ||||
-rw-r--r-- | nuttx/arch/x86/include/i486/io.h | 153 | ||||
-rwxr-xr-x | nuttx/arch/x86/include/i486/irq.h | 178 | ||||
-rwxr-xr-x | nuttx/arch/x86/include/i486/limits.h | 81 | ||||
-rwxr-xr-x | nuttx/arch/x86/include/i486/types.h | 97 |
5 files changed, 617 insertions, 0 deletions
diff --git a/nuttx/arch/x86/include/i486/arch.h b/nuttx/arch/x86/include/i486/arch.h new file mode 100755 index 000000000..89901cb0a --- /dev/null +++ b/nuttx/arch/x86/include/i486/arch.h @@ -0,0 +1,108 @@ +/**************************************************************************** + * arch/x86/include/i486/arch.h + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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. Neither the name NuttX 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT OWNER OR CONTRIBUTORS 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 should never be included directed but, rather, + * only indirectly through nuttx/arch.h + */ + +#ifndef __ARCH_X86_INCLUDE_I486_ARCH_H +#define __ARCH_X86_INCLUDE_I486_ARCH_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* FLAGS bits */ + +#define X86_FLAGS_CF (1 << 0) /* Bit 0: Carry Flag */ + /* Bit 1: Reserved */ +#define X86_FLAGS_PF (1 << 2) /* Bit 2: Parity Flag */ + /* Bit 3: Reserved */ +#define X86_FLAGS_AF (1 << 4) /* Bit 4: Auxillary carry Flag */ + /* Bit 5: Reserved */ +#define X86_FLAGS_ZF (1 << 6) /* Bit 6: Zero Flag */ +#define X86_FLAGS_SF (1 << 7) /* Bit 7: Sign Flag */ +#define X86_FLAGS_TF (1 << 8) /* Bit 8: Trap Flag */ +#define X86_FLAGS_IF (1 << 9) /* Bit 9: Interrupt Flag */ +#define X86_FLAGS_DF (1 << 10) /* Bit 10: Direction Flag */ +#define X86_FLAGS_OF (1 << 11) /* Bit 11: Overflow Flag */ +#define X86_FLAGS_IOPL_SHIFT (12) /* Bits 12-13: IOPL mask (286+ only)*/ +#define X86_FLAGS_IOPL_MASK (3 << X86_FLAGS_IOPL_SHIFT) +#define X86_FLAGS_NT (1 << 14) /* Bit 14: Nested Task */ + /* Bit 15: Reserved */ + +/* EFLAGS bits (Extend the basic FLAGS bit definitions) */ + +#define X86_EFLAGS_RF (1 << 16) /* Bit 16: Resume Flag (386+ only) */ +#define X86_EFLAGS_VM (1 << 17) /* Bit 17: Virtual Mode (386+ only) */ +#define X86_EFLAGS_AC (1 << 18) /* Bit 18: Alignment Check (486SX+ only) */ +#define X86_EFLAGS_VIF (1 << 19) /* Bit 19: Virtual Interrupt Flag (Pentium+) */ +#define X86_EFLAGS_VIP (1 << 20) /* Bit 20: Virtual Interrupt Pending (Pentium+) */ +#define X86_EFLAGS_ID (1 << 21) /* Bit 21: CPUID detection flag (Pentium+) */ + +/**************************************************************************** + * Inline functions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __ARCH_X86_INCLUDE_I486_ARCH_H */ + diff --git a/nuttx/arch/x86/include/i486/io.h b/nuttx/arch/x86/include/i486/io.h new file mode 100644 index 000000000..7a56ef626 --- /dev/null +++ b/nuttx/arch/x86/include/i486/io.h @@ -0,0 +1,153 @@ +/**************************************************************************** + * arch/x86/include/i486/io.h + * arch/chip/io.h + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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. Neither the name NuttX 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT OWNER OR CONTRIBUTORS 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 should never be included directed but, rather, only indirectly + * through arch/io.h + */ + +#ifndef __ARCH_X86_INCLUDE_I486_IO_H +#define __ARCH_X86_INCLUDE_I486_IO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stdint.h> + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + + #ifndef __ASSEMBLY__ + +/**************************************************************************** + * Inline functions + ****************************************************************************/ + +/* Standard x86 Port I/O */ + +static inline void outb(uint8_t regval, uint16_t port) +{ + asm volatile( + "\toutb %0,%1\n" + : + : "a" (regval), "dN" (port) + ); +} + +static inline uint8_t inb(uint16_t port) +{ + uint8_t regval; + asm volatile( + "\tinb %1,%0\n" + : "=a" (regval) + : "dN" (port) + ); + return regval; +} + +static inline void outw(uint16_t regval, uint16_t port) +{ + asm volatile( + "\toutw %0,%1\n" + : + : "a" (regval), "dN" (port) + ); +} + +static inline uint16_t inw(uint16_t port) +{ + uint16_t regval; + + asm volatile( + "\tinw %1,%0\n" + : "=a" (regval) + : "dN" (port) + ); + return regval; +} + +static inline void outl(uint32_t regval, uint16_t port) +{ + asm volatile( + "\toutl %0,%1\n" + : + : "a" (regval), "dN" (port) + ); +} + +static inline uint32_t inl(uint32_t port) +{ + uint32_t regval; + asm volatile( + "\tinl %1,%0\n" + : "=a" (regval) + : "dN" (port) + ); + return regval; +} + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN void outp(char p, char c); +EXTERN char inp(char p); + +#undef EXTERN +#ifdef __cplusplus +} +#endif +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __ARCH_X86_INCLUDE_I486_IO_H */ diff --git a/nuttx/arch/x86/include/i486/irq.h b/nuttx/arch/x86/include/i486/irq.h new file mode 100755 index 000000000..d24e335f1 --- /dev/null +++ b/nuttx/arch/x86/include/i486/irq.h @@ -0,0 +1,178 @@ +/**************************************************************************** + * arch/x86/include/i486/irq.h + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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. Neither the name NuttX 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT OWNER OR CONTRIBUTORS 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 should never be included directed but, rather, only indirectly + * through nuttx/irq.h + */ + +#ifndef __ARCH_X86_INCLUDE_I486_IRQ_H +#define __ARCH_X86_INCLUDE_I486_IRQ_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#ifdef __ASSEMBLY__ +# include <stdint.h> +# include <stdbool.h> +# include <arch/arch.h> +#endif + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */ + +#ifdef __ASSEMBLY__ +# define REG_EBX (0*4) +# define REG_ESI (1*4) +# define REG_EDI (2*4) +# define REG_EBP (3*4) +# define REG_SP (4*4) +# define REG_PC (5*4) +#else +# define REG_EBX (0) +# define REG_ESI (1) +# define REG_EDI (2) +# define REG_EBP (3) +# define REG_SP (4) +# define REG_PC (5) +#endif /* __ASSEMBLY__ */ + +#define XCPTCONTEXT_REGS (6) +#define XCPTCONTEXT_SIZE (6 * XCPTCONTEXT_REGS) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* This struct defines the way the registers are stored */ + +#ifndef __ASSEMBLY__ +struct xcptcontext +{ + void *sigdeliver; /* Actual type is sig_deliver_t */ + + /* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */ + + uint32_t regs[XCPTCONTEXT_REGS]; +}; +#endif + +/**************************************************************************** + * Inline functions + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/* Get the current FLAGS register contents */ + +static inline irqstate_t irqflags() +{ + irqstate_t flags; + + asm volatile( + "\tpushf\n" + "\tpop %0\n" + : "=rm" (flags) + : + : "memory"); + return flags; +} + +/* Get a sample of the FLAGS register, determine if interrupts are disabled */ + +static inline bool irqdisabled(irqstate_t flags) +{ + return ((flags & X86_FLAGS_IF) == 0); +} + +/* Disable interrupts unconditionally */ + +static inline void irqdisable(void) +{ + asm volatile("cli": : :"memory"); +} + +/* Enable interrupts unconditionally */ + +static inline void irqenable(void) +{ + asm volatile("sti": : :"memory"); +} + +/* Disable interrupts, but return previous interrupt state */ + +static inline irqstate_t irqsave(void) +{ + irqstate_t flags = irqflags(); + irqdisable(); + return flags; +} + +/* Conditionally disable interrupts */ + +static inline void irqrestore(irqstate_t flags) +{ + if (irqdisabled(flags)) + { + irqdisable(); + } +} + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __ARCH_X86_INCLUDE_I486_IRQ_H */ + diff --git a/nuttx/arch/x86/include/i486/limits.h b/nuttx/arch/x86/include/i486/limits.h new file mode 100755 index 000000000..ac0755ef9 --- /dev/null +++ b/nuttx/arch/x86/include/i486/limits.h @@ -0,0 +1,81 @@ +/**************************************************************************** + * arch/x86/include/i486/limits.h + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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. Neither the name NuttX 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT OWNER OR CONTRIBUTORS 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. + * + ****************************************************************************/ + +#ifndef __ARCH_X86_INCLUDE_I486_LIMITS_H +#define __ARCH_X86_INCLUDE_I486_LIMITS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +#define CHAR_BIT 8 +#define SCHAR_MIN 0x80 +#define SCHAR_MAX 0x7f +#define UCHAR_MAX 0xff + +/* These could be different on machines where char is unsigned */ + +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX + +#define SHRT_MIN 0x8000 +#define SHRT_MAX 0x7fff +#define USHRT_MAX 0xffff + +#define INT_MIN 0x80000000 +#define INT_MAX 0x7fffffff +#define UINT_MAX 0xffffffff + +/* These change on 32-bit and 64-bit platforms */ + +#define LONG_MAX 0x80000000 +#define LONG_MIN 0x7fffffff +#define ULONG_MAX 0xffffffff + +#define LLONG_MAX 0x8000000000000000 +#define LLONG_MIN 0x7fffffffffffffff +#define ULLONG_MAX 0xffffffffffffffff + +/* A pointer is 4 bytes */ + +#define PTR_MIN 0x80000000 +#define PTR_MAX 0x7fffffff +#define UPTR_MAX 0xffffffff + +#endif /* __ARCH_X86_INCLUDE_I486_LIMITS_H */ diff --git a/nuttx/arch/x86/include/i486/types.h b/nuttx/arch/x86/include/i486/types.h new file mode 100755 index 000000000..88379fd0f --- /dev/null +++ b/nuttx/arch/x86/include/i486/types.h @@ -0,0 +1,97 @@ +/************************************************************************ + * arch/x86/include/i486/types.h + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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. Neither the name NuttX 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT OWNER OR CONTRIBUTORS 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 should never be included directed but, rather, only + * indirectly through arch/types.h (which is, in turn only accessed + * through sys/types.h or stdint.h). + */ + +#ifndef __ARCH_X86_INCLUDE_I486_TYPES_H +#define __ARCH_X86_INCLUDE_I486_TYPES_H + +/************************************************************************ + * Included Files + ************************************************************************/ + +/************************************************************************ + * Definitions + ************************************************************************/ + +/************************************************************************ + * Type Declarations + ************************************************************************/ + +#ifndef __ASSEMBLY__ + +/* These are the sizes of the standard integer types. NOTE that these type + * names have a leading underscore character. This file will be included + * (indirectly) by include/stdint.h and typedef'ed to the final name without + * the underscore character. This roundabout way of doings things allows + * the stdint.h to be removed from the include/ directory in the event that + * the user prefers to use the definitions provided by their toolchain header + * files + */ + +typedef char _int8_t; +typedef unsigned char _uint8_t; + +typedef short _int16_t; +typedef unsigned short _uint16_t; + +typedef int _int32_t; +typedef unsigned int _uint32_t; + +typedef long long _int64_t; +typedef unsigned long long _uint64_t; +#define __INT64_DEFINED + +/* A pointer is 4 bytes */ + +typedef unsigned int _intptr_t; +typedef unsigned int _uintptr_t; + +/* This is the size of the interrupt state save returned by + * irqsave() + */ + +typedef unsigned int irqstate_t; + +#endif /* __ASSEMBLY__ */ + +/************************************************************************ + * Global Function Prototypes + ************************************************************************/ + +#endif /* __ARCH_X86_INCLUDE_I486_TYPES_H */ |