mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
Remove the arch/ subdirectory; replace it with a submodule
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if ARCH_X86
|
||||
comment "x86 Configuration Options"
|
||||
|
||||
choice
|
||||
prompt "x86 chip selection"
|
||||
default ARCH_I486
|
||||
|
||||
config ARCH_I486
|
||||
bool "i486"
|
||||
select ARCH_X86_HAVE_32BIT
|
||||
---help---
|
||||
Intel i486 architecture
|
||||
|
||||
endchoice
|
||||
|
||||
config ARCH_CHIP_QEMU
|
||||
bool "Qemu x86 emulation"
|
||||
default n
|
||||
---help---
|
||||
Intel i486 architecture
|
||||
|
||||
config ARCH_CHIP
|
||||
string
|
||||
default "qemu" if ARCH_CHIP_QEMU
|
||||
|
||||
config ARCH_X86_HAVE_32BIT
|
||||
bool
|
||||
default n
|
||||
|
||||
config ARCH_X86_M32
|
||||
bool "Build 32-bit system with a 64-bit machine"
|
||||
default n
|
||||
depends on ARCH_X86_HAVE_32BIT
|
||||
---help---
|
||||
If you are building for a 32-bit target using a native 64-bit
|
||||
toolchain, then you need to add compilation options to select the
|
||||
32-bit target. Selecting this option will add the -m32 option to
|
||||
the compiler command line.
|
||||
|
||||
source arch/x86/src/common/Kconfig
|
||||
if ARCH_I486
|
||||
source arch/x86/src/i486/Kconfig
|
||||
endif # ARCH_I486
|
||||
if ARCH_CHIP_QEMU
|
||||
source arch/x86/src/qemu/Kconfig
|
||||
endif # ARCH_CHIP_QEMU
|
||||
endif # ARCH_X86
|
||||
@@ -1,3 +0,0 @@
|
||||
/chip
|
||||
/board
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
arch/x86/include/README.txt
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This directory holds x86-specific header files. The top-level header files in
|
||||
arch/x86/include simply include corresponding header files from lower lower-
|
||||
level chip-specific and architecture-specific directories.
|
||||
|
||||
Architecture-Specific Directories
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Architecture-specific directories hold common header files for specific x86
|
||||
architectures. Separating these header file makes it easy to manage such
|
||||
things as differences in sizeof(long) on 32- and 64-bit x86 architectures.
|
||||
|
||||
i486
|
||||
This directory holds definitions appropriate for any instantiation of the
|
||||
32-bit i486 architecture.
|
||||
|
||||
Chip-Specific directories
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The same x86 architecture may be realized in different chip implementations.
|
||||
For SoC chips, in particular, on-chip devices and differing interrupt
|
||||
structures may require special, chip-specific definitions in these chip-
|
||||
specific directories.
|
||||
|
||||
qemu
|
||||
This is the implementation of NuttX on the QEMU x86 simulation.
|
||||
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/arch.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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/arch.h
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_X86_INCLUDE_ARCH_H
|
||||
#define __ARCH_X86_INCLUDE_ARCH_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/* Include chip-specific definitions */
|
||||
|
||||
# include <arch/chip/arch.h>
|
||||
|
||||
/* Include architecture-specific definitions */
|
||||
|
||||
#ifdef CONFIG_ARCH_I486
|
||||
# include <arch/i486/arch.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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_ARCH_H */
|
||||
@@ -1,454 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/i486/arch.h
|
||||
*
|
||||
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <nuttx/compiler.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor 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+) */
|
||||
|
||||
/* Programmable Interrupt Controller (PIC) */
|
||||
|
||||
/* Operational Control Words
|
||||
*
|
||||
* The first instruction the Operation Control Word 1 (OCW1) to set which
|
||||
* IRQ's to mask and which IRQ's not to.
|
||||
*/
|
||||
|
||||
#define PIC1_OCW1 0x20
|
||||
#define PIC2_OCW1 0xa0
|
||||
|
||||
# define PIC1_OCW1_IRQ0 (1 << 0) /* IRQ0 System Timer */
|
||||
# define PIC1_OCW1_IRQ1 (1 << 1) /* IRQ1 Keyboard */
|
||||
# define PIC1_OCW1_IRQ2 (1 << 2) /* IRQ2 PIC2 */
|
||||
# define PIC1_OCW1_IRQ3 (1 << 3) /* IRQ3 Serial Port */
|
||||
# define PIC1_OCW1_IRQ4 (1 << 4) /* IRQ4 Serial Port */
|
||||
# define PIC1_OCW1_IRQ5 (1 << 5) /* IRQ5 Reserved/Sound Card */
|
||||
# define PIC1_OCW1_IRQ6 (1 << 6) /* IRQ6 Floppy Disk Controller */
|
||||
# define PIC1_OCW1_IRQ7 (1 << 7) /* IRQ7 Parallel Port */
|
||||
# define PIC1_OCW1_ALL
|
||||
|
||||
# define PIC2_OCW1_IRQ8 (1 << 0) /* IRQ8 Real Time Clock */
|
||||
# define PIC2_OCW1_IRQ9 (1 << 1) /* IRQ9 Redirected IRQ2 */
|
||||
# define PIC2_OCW1_IRQ10 (1 << 2) /* IRQ10 Reserved */
|
||||
# define PIC2_OCW1_IRQ11 (1 << 3) /* IRQ11 Reserved */
|
||||
# define PIC2_OCW1_IRQ12 (1 << 4) /* IRQ12 PS/2 Mouse */
|
||||
# define PIC2_OCW1_IRQ13 (1 << 5) /* IRQ13 Maths Co-Processor */
|
||||
# define PIC2_OCW1_IRQ14 (1 << 6) /* IRQ14 Hard Disk Drive */
|
||||
# define PIC2_OCW1_IRQ15 (1 << 7) /* IRQ15 Reserved */
|
||||
# define PIC2_OCW1_ALL
|
||||
|
||||
/* Operation Control Word 2 selects how the End of Interrupt (EOI) procedure
|
||||
* works. The only thing of interest to us in this register is the non-
|
||||
* specific EOI command, which we must send at the end of our ISR's.
|
||||
*/
|
||||
|
||||
#define PIC1_OCW2 0x20
|
||||
#define PIC2_OCW2 0xa0
|
||||
|
||||
# define PIC_OCW2_ACT_SHIFT (0)
|
||||
# define PIC_OCW2_ACT_MASK (7 << PIC_OCW2_ACT_SHIFT)
|
||||
# define PIC1_OCW2_ACT_IRQ0 (0 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 0 */
|
||||
# define PIC1_OCW2_ACT_IRQ1 (1 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 1 */
|
||||
# define PIC1_OCW2_ACT_IRQ2 (2 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 2 */
|
||||
# define PIC1_OCW2_ACT_IRQ3 (3 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 3 */
|
||||
# define PIC1_OCW2_ACT_IRQ4 (4 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 4 */
|
||||
# define PIC1_OCW2_ACT_IRQ5 (5 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 5 */
|
||||
# define PIC1_OCW2_ACT_IRQ6 (6 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 6 */
|
||||
# define PIC1_OCW2_ACT_IRQ7 (7 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 7 */
|
||||
|
||||
# define PIC2_OCW2_ACT_IRQ8 (0 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 8 */
|
||||
# define PIC2_OCW2_ACT_IRQ9 (1 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 9 */
|
||||
# define PIC2_OCW2_ACT_IRQ10 (2 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 10 */
|
||||
# define PIC2_OCW2_ACT_IRQ11 (3 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 11 */
|
||||
# define PIC2_OCW2_ACT_IRQ12 (4 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 12 */
|
||||
# define PIC2_OCW2_ACT_IRQ13 (5 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 13 */
|
||||
# define PIC2_OCW2_ACT_IRQ14 (6 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 14 */
|
||||
# define PIC2_OCW2_ACT_IRQ15 (7 << PIC_OCW2_ACT_SHIFT) /* Act on IRQ 15 */
|
||||
|
||||
# define PIC_OCW2_EOI_SHIFT (5)
|
||||
# define PIC_OCW2_EOI_MASK (7 << PIC_OCW2_EOI_SHIFT)
|
||||
# define PIC_OCW2_EOI_AUTO (0 << PIC_OCW2_EOI_SHIFT) /* Rotate in Auto EOI Mode (Clear) */
|
||||
# define PIC_OCW2_EOI_NONSPEC (1 << PIC_OCW2_EOI_SHIFT) /* Non Specific EOI */
|
||||
# define PIC_OCW2_EOI_SPEC (3 << PIC_OCW2_EOI_SHIFT) /* Specific EOI */
|
||||
# define PIC_OCW2_EOI_RAUTO (4 << PIC_OCW2_EOI_SHIFT) /* Rotate in Auto EOI Mode (Set) */
|
||||
# define PIC_OCW2_EOI_RNSPEC (5 << PIC_OCW2_EOI_SHIFT) /* Rotate on Non-Specific EOI */
|
||||
# define PIC_OCW2_EOI_PRIO (6 << PIC_OCW2_EOI_SHIFT) /* Set Priority Command (Use Bits 2:0) */
|
||||
# define PIC_OCW2_EOI_RSPEC (7 << PIC_OCW2_EOI_SHIFT) /* Rotate on Specific EOI (Use Bits 2:0) */
|
||||
|
||||
/* Operation Control Word 3. Bits 0 and 1 bitsenable us to read the status
|
||||
* of the Interrupt Request Register (IRR) and the In-Service Register (ISR).
|
||||
* This is done by setting the appropriate bits correctly and reading the
|
||||
* register at the Base Address.
|
||||
*
|
||||
* For example if we wanted to read the In-Service Register (ISR), then we
|
||||
* would set both bits 1 and 0 to 1. The next read to the base register,
|
||||
* (0x20 for PIC1 or 0xa0 for PIC2) will return the status of the In-Service
|
||||
* Register.
|
||||
*/
|
||||
|
||||
#define PIC1_OCW3 0x20
|
||||
#define PIC2_OCW3 0xa0
|
||||
|
||||
# define PIC_OCW3_PCMD_SHIFT (0) /* Poll command */
|
||||
# define PIC_OCW3_PCMD_MASK (3 << PIC_OCW3_PCMD_SHIFT)
|
||||
# define PIC_OCW3_PCMD_IRR (2 << PIC_OCW3_PCMD_SHIFT) /* Next Read Returns Interrupt Request Register */
|
||||
# define PIC_OCW3_PCMD_ISR (3 << PIC_OCW3_PCMD_SHIFT) /* Next Read Returns In-Service Register */
|
||||
# define PIC_OCW3_POLLCMD (1 << 2) /* Poll command */
|
||||
# define PIC_OCW3_ONE (1 << 3) /* Must be set to 1 */
|
||||
# define PIC_OCW3_SM_SHIFT (5)
|
||||
# define PIC_OCW3_SM_MASK (3 << PIC_OCW3_SM_SHIFT)
|
||||
# define PIC_OCW3_RSM (2 << PIC_OCW3_SM_SHIFT) /* Reset Special Mask */
|
||||
# define PIC_OCW3_SSM (3 << PIC_OCW3_SM_SHIFT) /* Set Special Mask */
|
||||
|
||||
/* If the PIC has been reset, it must be initialized with 2 to 4 Initialization
|
||||
* Command Words (ICW) before it will accept and process Interrupt Requests. The
|
||||
* following outlines the four possible Initialization Command Words.
|
||||
*/
|
||||
|
||||
#define PIC1_ICW1 0x20
|
||||
#define PIC2_ICW1 0xa0
|
||||
|
||||
# define PIC_ICW1_ICW4 (1 << 0) /* Will be Sending ICW4 (no ICW4) */
|
||||
# define PIC_ICW1_SINGLE (1 << 1) /* Single PIC (vs. Cascaded pics) */
|
||||
# define PIC_ICW1_INTERVAL (1 << 2) /* Call Address Interval of 4 (vs 8) */
|
||||
# define PIC_ICW1_LEVEL (1 << 3) /* Level Triggered Interrupts (vs Edge) */
|
||||
# define PIC_ICW1_ICW1 (1 << 4) /* Must be set to 1 for ICW1 */
|
||||
# define PIC_ICW1_VEC_SHIFT (5) /* Interrupt Vector Addresses for MCS-80/85 Mode */
|
||||
# define PIC_ICW1_VEC_MASK (7 << PIC_ICW1_VEC_SHIFT)
|
||||
|
||||
/* Initialization Command Word 2 (ICW2) selects which vector information is
|
||||
* released onto the bus, during the 2nd INTA Pulse. Using the 8086 mode,
|
||||
* only bits 7:3 need to be used. This will be 00001000 (0x08) for PIC1 and
|
||||
* 01110000 (0x70) for PIC2. If you wish to relocate the IRQ Vector Table,
|
||||
* then you can use this register.
|
||||
*/
|
||||
|
||||
#define PIC1_ICW2 0x21
|
||||
#define PIC2_ICW2 0xa1
|
||||
|
||||
/* There are two different Initialization Command Word 3's. One is used, if
|
||||
* the PIC is a master, while the other is used for slaves.
|
||||
*/
|
||||
|
||||
#define PIC1_ICW3 0x21
|
||||
#define PIC2_ICW3 0xa1
|
||||
|
||||
/* Master ICW3 */
|
||||
|
||||
# define PIC1_ICW3_IRQ0 (1 << 0) /* IRQ0 is connected to a Slave */
|
||||
# define PIC1_ICW3_IRQ1 (1 << 1) /* IRQ1 is connected to a Slave */
|
||||
# define PIC1_ICW3_IRQ2 (1 << 2) /* IRQ2 is connected to a Slave */
|
||||
# define PIC1_ICW3_IRQ3 (1 << 3) /* IRQ3 is connected to a Slave */
|
||||
# define PIC1_ICW3_IRQ4 (1 << 4) /* IRQ4 is connected to a Slave */
|
||||
# define PIC1_ICW3_IRQ5 (1 << 5) /* IRQ5 is connected to a Slave */
|
||||
# define PIC1_ICW3_IRQ6 (1 << 6) /* IRQ6 is connected to a Slave */
|
||||
# define PIC1_ICW3_IRQ7 (1 << 7) /* IRQ7 is connected to a Slave */
|
||||
|
||||
/* And for the slave device, the ICW3 below is used. */
|
||||
|
||||
# define PIC_ICW3_SID_MASK (0) /* Slave ID */
|
||||
# define PIC_ICW3_SID_SHIFT (7 << PIC_ICW3_SID_MASK)
|
||||
# define PIC_ICW3_SID0 (0 << PIC_ICW3_SID_MASK) /* Slave 0 */
|
||||
# define PIC_ICW3_SID1 (1 << PIC_ICW3_SID_MASK) /* Slave 1 */
|
||||
# define PIC_ICW3_SID2 (2 << PIC_ICW3_SID_MASK) /* Slave 2 */
|
||||
# define PIC_ICW3_SID3 (3 << PIC_ICW3_SID_MASK) /* Slave 3 */
|
||||
# define PIC_ICW3_SID4 (4 << PIC_ICW3_SID_MASK) /* Slave 4 */
|
||||
# define PIC_ICW3_SID5 (5 << PIC_ICW3_SID_MASK) /* Slave 5 */
|
||||
# define PIC_ICW3_SID6 (6 << PIC_ICW3_SID_MASK) /* Slave 6 */
|
||||
# define PIC_ICW3_SID7 (7 << PIC_ICW3_SID_MASK) /* Slave 7 */
|
||||
|
||||
#define PIC1_ICW4 0x21
|
||||
#define PIC2_ICW4 0xa1
|
||||
|
||||
# define PIC_ICW4_FNM (1 << 4) /* Special Fully Nested Mode */
|
||||
# define PIC_ICW4_BMODE_SHIFT (2) /* Bufferd mode */
|
||||
# define PIC_ICW4_BMODE_MASK (3 << PIC_ICW4_BMODE_SHIFT)
|
||||
# define PIC_ICW4_BMODE_NON (0 << PIC_ICW4_BMODE_SHIFT) /* Non - Buffered Mode */
|
||||
# define PIC_ICW4_BMODE_SLAVE (2 << PIC_ICW4_BMODE_SHIFT) /* Buffered Mode - Slave */
|
||||
# define PIC_ICW4_BMODE_MSTR (3 << PIC_ICW4_BMODE_SHIFT) /* Buffered Mode - Master */
|
||||
# define PIC_ICW4_AEOI (1 << 1) /* Auto EOI */
|
||||
# define PIC_ICW4_808xMODE (1 << 0) /* 8086/8080 Mode (vs MCS-80/85) */
|
||||
|
||||
/* Interrupt Mask Register */
|
||||
|
||||
#define PIC1_IMR 0x21
|
||||
#define PIC2_IMR 0xa1
|
||||
|
||||
# define PIC1_IMR_IRQ0 (1 << 0) /* IRQ0 System Timer */
|
||||
# define PIC1_IMR_IRQ1 (1 << 1) /* IRQ1 Keyboard */
|
||||
# define PIC1_IMR_IRQ2 (1 << 2) /* IRQ2 PIC2 */
|
||||
# define PIC1_IMR_IRQ3 (1 << 3) /* IRQ3 Serial Port */
|
||||
# define PIC1_IMR_IRQ4 (1 << 4) /* IRQ4 Serial Port */
|
||||
# define PIC1_IMR_IRQ5 (1 << 5) /* IRQ5 Reserved/Sound Card */
|
||||
# define PIC1_IMR_IRQ6 (1 << 6) /* IRQ6 Floppy Disk Controller */
|
||||
# define PIC1_IMR_IRQ7 (1 << 7) /* IRQ7 Parallel Port */
|
||||
# define PIC1_IMR_ALL 0xff
|
||||
|
||||
# define PIC2_IMR_IRQ8 (1 << 0) /* IRQ8 Real Time Clock */
|
||||
# define PIC2_IMR_IRQ9 (1 << 1) /* IRQ9 Redirected IRQ2 */
|
||||
# define PIC2_IMR_IRQ10 (1 << 2) /* IRQ10 Reserved */
|
||||
# define PIC2_IMR_IRQ11 (1 << 3) /* IRQ11 Reserved */
|
||||
# define PIC2_IMR_IRQ12 (1 << 4) /* IRQ12 PS/2 Mouse */
|
||||
# define PIC2_IMR_IRQ13 (1 << 5) /* IRQ13 Maths Co-Processor */
|
||||
# define PIC2_IMR_IRQ14 (1 << 6) /* IRQ14 Hard Disk Drive */
|
||||
# define PIC2_IMR_IRQ15 (1 << 7) /* IRQ15 Reserved */
|
||||
# define PIC2_IMR_ALL 0xff
|
||||
|
||||
/* Programmable Interrupt Timer Definitions */
|
||||
|
||||
#define PIT_REG_COUNTER0 0x40
|
||||
#define PIT_REG_COUNTER1 0x41
|
||||
#define PIT_REG_COUNTER2 0x42
|
||||
#define PIT_REG_COMMAND 0x43
|
||||
|
||||
/* PIT command bit defintions */
|
||||
|
||||
# define PIT_OCW_BINCOUNT_BCD (1 << 0) /* vs binary */
|
||||
# define PIT_OCW_MODE_SHIFT (1)
|
||||
# define PIT_OCW_MODE_MASK (7 << PIT_OCW_MODE_SHIFT)
|
||||
# define PIT_OCW_MODE_TMCNT (0 << PIT_OCW_MODE_SHIFT) /* Terminal count */
|
||||
# define PIT_OCW_MODE_ONESHOT (1 << PIT_OCW_MODE_SHIFT) /* One shot */
|
||||
# define PIT_OCW_MODE_RATEGEN (2 << PIT_OCW_MODE_SHIFT) /* Rate gen */
|
||||
# define PIT_OCW_MODE_SQUARE (3 << PIT_OCW_MODE_SHIFT) /* Square wave generation */
|
||||
# define PIT_OCW_MODE_SWTRIG (4 << PIT_OCW_MODE_SHIFT) /* Software trigger */
|
||||
# define PIT_OCW_MODE_HWTRIG (5 << PIT_OCW_MODE_SHIFT) /* Hardware trigger */
|
||||
# define PIT_OCW_RL_SHIFT (4)
|
||||
# define PIT_OCW_RL_MASK (3 << PIT_OCW_RL_SHIFT)
|
||||
# define PIT_OCW_RL_LATCH (0 << PIT_OCW_RL_SHIFT)
|
||||
# define PIT_OCW_RL_LSBONLY (1 << PIT_OCW_RL_SHIFT)
|
||||
# define PIT_OCW_RL_MSBONLY (2 << PIT_OCW_RL_SHIFT)
|
||||
# define PIT_OCW_RL_DATA (3 << PIT_OCW_RL_SHIFT)
|
||||
# define PIT_OCW_COUNTER_SHIFT (6)
|
||||
# define PIT_OCW_COUNTER_MASK (3 << PIT_OCW_COUNTER_SHIFT)
|
||||
# define PIT_OCW_COUNTER_0 (0 << PIT_OCW_COUNTER_SHIFT)
|
||||
# define PIT_OCW_COUNTER_1 (1 << PIT_OCW_COUNTER_SHIFT)
|
||||
# define PIT_OCW_COUNTER_2 (2 << PIT_OCW_COUNTER_SHIFT)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* GDT data structures ******************************************************
|
||||
*
|
||||
* The Global Descriptor Table or GDT is a data structure used by Intel x86-
|
||||
* family processors starting with the 80286 in order to define the
|
||||
* characteristics of the various memory areas used during program execution,
|
||||
* for example the base address, the size and access privileges like
|
||||
* executability and writability. These memory areas are called segments in
|
||||
* Intel terminology.
|
||||
*/
|
||||
|
||||
/* This structure defines one segment */
|
||||
|
||||
struct gdt_entry_s
|
||||
{
|
||||
uint16_t lowlimit; /* The lower 16 bits of the limit */
|
||||
uint16_t lowbase; /* The lower 16 bits of the base */
|
||||
uint8_t midbase; /* The next 8 bits of the base */
|
||||
uint8_t access; /* Access flags, determine ring segment can be used in */
|
||||
uint8_t granularity;
|
||||
uint8_t hibase; /* The last 8 bits of the base */
|
||||
} packed_struct;
|
||||
|
||||
/* This structure refers to the array of GDT entries, and is in the format
|
||||
* required by the lgdt instruction.
|
||||
*/
|
||||
|
||||
struct gdt_ptr_s
|
||||
{
|
||||
uint16_t limit; /* The upper 16 bits of all selector limits */
|
||||
uint32_t base; /* The address of the first GDT entry */
|
||||
} packed_struct;
|
||||
|
||||
/* IDT data structures ******************************************************
|
||||
*
|
||||
* The Interrupt Descriptor Table (IDT) is a data structure used by the x86
|
||||
* architecture to implement an interrupt vector table. The IDT is used by the
|
||||
* processor to determine the correct response to interrupts and exceptions.
|
||||
*/
|
||||
|
||||
struct idt_entry_s
|
||||
{
|
||||
uint16_t lobase; /* Lower 16-bits of vector address for interrupt */
|
||||
uint16_t sel; /* Kernel segment selector */
|
||||
uint8_t zero; /* This must always be zero */
|
||||
uint8_t flags; /* (See documentation) */
|
||||
uint16_t hibase; /* Upper 16-bits of vector address for interrupt */
|
||||
} packed_struct;
|
||||
|
||||
/* A struct describing a pointer to an array of interrupt handlers. This is
|
||||
* in a format suitable for giving to 'lidt'.
|
||||
*/
|
||||
|
||||
struct idt_ptr_s
|
||||
{
|
||||
uint16_t limit;
|
||||
uint32_t base; /* The address of the first GDT entry */
|
||||
} packed_struct;
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/* Return stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp()
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmovl %%esp, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/* Get segment registers */
|
||||
|
||||
static inline uint32_t up_getds()
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ds, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getcs()
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%cs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getss()
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ss, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
void gdt_flush(uint32_t gdt_addr);
|
||||
void idt_flush(uint32_t idt_addr);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_X86_INCLUDE_I486_ARCH_H */
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/i486/io.h
|
||||
* arch/chip/io.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor 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(uint16_t port)
|
||||
{
|
||||
uint32_t regval;
|
||||
asm volatile(
|
||||
"\tinl %1,%0\n"
|
||||
: "=a" (regval)
|
||||
: "dN" (port)
|
||||
);
|
||||
return regval;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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_IO_H */
|
||||
@@ -1,288 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/i486/irq.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
# include <stdbool.h>
|
||||
# include <arch/arch.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* ISR and IRQ numbers */
|
||||
|
||||
#define ISR0 0 /* Division by zero exception */
|
||||
#define ISR1 1 /* Debug exception */
|
||||
#define ISR2 2 /* Non maskable interrupt */
|
||||
#define ISR3 3 /* Breakpoint exception */
|
||||
#define ISR4 4 /* 'Into detected overflow' */
|
||||
#define ISR5 5 /* Out of bounds exception */
|
||||
#define ISR6 6 /* Invalid opcode exception */
|
||||
#define ISR7 7 /* No coprocessor exception */
|
||||
#define ISR8 8 /* Double fault (pushes an error code) */
|
||||
#define ISR9 9 /* Coprocessor segment overrun */
|
||||
#define ISR10 10 /* Bad TSS (pushes an error code) */
|
||||
#define ISR11 11 /* Segment not present (pushes an error code) */
|
||||
#define ISR12 12 /* Stack fault (pushes an error code) */
|
||||
#define ISR13 13 /* General protection fault (pushes an error code) */
|
||||
#define ISR14 14 /* Page fault (pushes an error code) */
|
||||
#define ISR15 15 /* Unknown interrupt exception */
|
||||
#define ISR16 16 /* Coprocessor fault */
|
||||
#define ISR17 17 /* Alignment check exception */
|
||||
#define ISR18 18 /* Machine check exception */
|
||||
#define ISR19 19 /* Reserved */
|
||||
#define ISR20 20 /* Reserved */
|
||||
#define ISR21 21 /* Reserved */
|
||||
#define ISR22 22 /* Reserved */
|
||||
#define ISR23 23 /* Reserved */
|
||||
#define ISR24 24 /* Reserved */
|
||||
#define ISR25 25 /* Reserved */
|
||||
#define ISR26 26 /* Reserved */
|
||||
#define ISR27 27 /* Reserved */
|
||||
#define ISR28 28 /* Reserved */
|
||||
#define ISR29 29 /* Reserved */
|
||||
#define ISR30 30 /* Reserved */
|
||||
#define ISR31 31 /* Reserved */
|
||||
|
||||
#define IRQ0 32 /* System timer (cannot be changed) */
|
||||
#define IRQ1 33 /* Keyboard controller (cannot be changed) */
|
||||
#define IRQ2 34 /* Cascaded signals from IRQs 8–15 */
|
||||
#define IRQ3 35 /* Serial port controller for COM2/4 */
|
||||
#define IRQ4 36 /* serial port controller for COM1/3 */
|
||||
#define IRQ5 37 /* LPT port 2 or sound card */
|
||||
#define IRQ6 38 /* Floppy disk controller */
|
||||
#define IRQ7 39 /* LPT port 1 or sound card */
|
||||
#define IRQ8 40 /* Real time clock (RTC) */
|
||||
#define IRQ9 41 /* Open interrupt/available or SCSI host adapter */
|
||||
#define IRQ10 42 /* Open interrupt/available or SCSI or NIC */
|
||||
#define IRQ11 43 /* Open interrupt/available or SCSI or NIC */
|
||||
#define IRQ12 44 /* Mouse on PS/2 connector */
|
||||
#define IRQ13 45 /* Math coprocessor */
|
||||
#define IRQ14 46 /* Primary ATA channel */
|
||||
#define IRQ15 47 /* Secondary ATA channel */
|
||||
|
||||
#define NR_IRQS 48
|
||||
|
||||
/* Common register save structgure created by up_saveusercontext() and by
|
||||
* ISR/IRQ interrupt processing.
|
||||
*/
|
||||
|
||||
#define REG_DS (0) /* Data segment selector */
|
||||
#define REG_EDI (1) /* Saved by pusha */
|
||||
#define REG_ESI (2) /* " " "" " " */
|
||||
#define REG_EBP (3) /* " " "" " " */
|
||||
#define REG_ESP (4) /* " " "" " " (NOTE 1)*/
|
||||
#define REG_EBX (5) /* " " "" " " */
|
||||
#define REG_EDX (6) /* " " "" " " */
|
||||
#define REG_ECX (7) /* " " "" " " */
|
||||
#define REG_EAX (8) /* " " "" " " */
|
||||
#define REG_IRQNO (9) /* Interrupt number (NOTE 2) */
|
||||
#define REG_ERRCODE (10) /* Error code (NOTE 2) */
|
||||
#define REG_EIP (11) /* Pushed by process on interrupt processing */
|
||||
#define REG_CS (12) /* " " "" " " "" " " " " */
|
||||
#define REG_EFLAGS (13) /* " " "" " " "" " " " " */
|
||||
#define REG_SP (14) /* " " "" " " "" " " " " */
|
||||
#define REG_SS (15) /* " " "" " " "" " " " " */
|
||||
|
||||
/* NOTE 1: Two versions of the ESP are saved: One from the interrupt
|
||||
* processing and one from pusha. Only the interrupt ESP (REG_SP) is used.
|
||||
* NOTE 2: This is not really state data. Rather, this is just a convenient
|
||||
* way to pass parameters from the interrupt handler to C cod.
|
||||
*/
|
||||
|
||||
#define XCPTCONTEXT_REGS (16)
|
||||
#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS)
|
||||
|
||||
/* Some special landmarks in the stack frame:
|
||||
*
|
||||
* TOP_PUSHA - The offset (in 32-bit words) from the beginning of the
|
||||
* save area on the stack to the value that should be in REG_ESP.
|
||||
* BOTTOM_PUSHA - The offset (in 32-bit words) from the stack position before
|
||||
* the interrupt occurred to the value that should be in REG_ESP.
|
||||
* save area on the stack to the value that should be in REG_ESP.
|
||||
* OFFSET_PRIO - The offset from the value of REG_ESP to the value of the
|
||||
* stack pointer before the interrupt occurred (assuming that a priority
|
||||
* change occurred.
|
||||
* OFFSET_PRIO - The offset from the value of REG_ESP to the value of the
|
||||
* stack pointer before the interrupt occurred (assuming that NO priority
|
||||
* change occurred.
|
||||
*/
|
||||
|
||||
#define TOP_PUSHA REG_IRQNO
|
||||
#define BOTTOM_PRIO (XCPTCONTEXT_REGS-REG_IRQNO)
|
||||
#define BOTTOM_NOPRIO (REG_SP-REG_IRQNO)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This struct defines the way the registers are stored */
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
struct xcptcontext
|
||||
{
|
||||
/* The following function pointer is non-zero if there are pending signals
|
||||
* to be processed.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
void *sigdeliver; /* Actual type is sig_deliver_t */
|
||||
|
||||
/* These are saved copies of instruction pointer and EFLAGS used during
|
||||
* signal processing.
|
||||
*/
|
||||
|
||||
uint32_t saved_eip;
|
||||
uint32_t saved_eflags;
|
||||
#endif
|
||||
|
||||
/* Register save area */
|
||||
|
||||
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.
|
||||
* If the X86_FLAGS_IF is cleared by cli, then interrupts are disabled. If
|
||||
* if the X86_FLAGS_IF is set by sti, then interrupts are enable.
|
||||
*/
|
||||
|
||||
static inline bool irqdisabled(irqstate_t flags)
|
||||
{
|
||||
return ((flags & X86_FLAGS_IF) == 0);
|
||||
}
|
||||
|
||||
static inline bool irqenabled(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 (irqenabled(flags))
|
||||
{
|
||||
irqenable();
|
||||
}
|
||||
}
|
||||
|
||||
static inline void system_call3(unsigned int nbr, uintptr_t parm1,
|
||||
uintptr_t parm2, uintptr_t parm3)
|
||||
{
|
||||
/* To be provided */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/i486/limits.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CHAR_BIT 8
|
||||
#define SCHAR_MIN (-SCHAR_MAX - 1)
|
||||
#define SCHAR_MAX 127
|
||||
#define UCHAR_MAX 255
|
||||
|
||||
/* These could be different on machines where char is unsigned */
|
||||
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
#define CHAR_MIN 0
|
||||
#define CHAR_MAX UCHAR_MAX
|
||||
#else
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#endif
|
||||
|
||||
#define SHRT_MIN (-SHRT_MAX - 1)
|
||||
#define SHRT_MAX 32767
|
||||
#define USHRT_MAX 65535U
|
||||
|
||||
#define INT_MIN (-INT_MAX - 1)
|
||||
#define INT_MAX 2147483647
|
||||
#define UINT_MAX 4294967295U
|
||||
|
||||
/* These change on 32-bit and 64-bit platforms */
|
||||
|
||||
#define LONG_MIN (-LONG_MAX - 1)
|
||||
#define LONG_MAX 2147483647L
|
||||
#define ULONG_MAX 4294967295UL
|
||||
|
||||
#define LLONG_MIN (-LLONG_MAX - 1)
|
||||
#define LLONG_MAX 9223372036854775807LL
|
||||
#define ULLONG_MAX 18446744073709551615ULL
|
||||
|
||||
/* A pointer is 4 bytes */
|
||||
|
||||
#define PTR_MIN (-PTR_MAX - 1)
|
||||
#define PTR_MAX 2147483647
|
||||
#define UPTR_MAX 4294967295U
|
||||
|
||||
#endif /* __ARCH_X86_INCLUDE_I486_LIMITS_H */
|
||||
@@ -1,138 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/i486/syscall.h
|
||||
*
|
||||
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 include/syscall.h or include/sys/sycall.h
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_X86_INCLUDE_I486_SYSCALL_H
|
||||
#define __ARCH_X86_INCLUDE_I486_SYSCALL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define SYS_syscall 0x80
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* SWI with SYS_ call number and six parameters */
|
||||
|
||||
uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, uintptr_t parm2,
|
||||
uintptr_t parm3, uintptr_t parm4, uintptr_t parm5,
|
||||
uintptr_t parm6);
|
||||
|
||||
/* SWI with SYS_ call number and no parameters */
|
||||
|
||||
static inline uintptr_t sys_call0(unsigned int nbr)
|
||||
{
|
||||
return sys_call6(nbr, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* SWI with SYS_ call number and one parameter */
|
||||
|
||||
static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1)
|
||||
{
|
||||
return sys_call6(nbr, parm1, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* SWI with SYS_ call number and two parameters */
|
||||
|
||||
static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1,
|
||||
uintptr_t parm2)
|
||||
{
|
||||
return sys_call6(nbr, parm1, parm2, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* SWI with SYS_ call number and three parameters */
|
||||
|
||||
static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1,
|
||||
uintptr_t parm2, uintptr_t parm3)
|
||||
{
|
||||
return sys_call6(nbr, parm1, parm2, parm3, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* SWI with SYS_ call number and four parameters */
|
||||
|
||||
static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1,
|
||||
uintptr_t parm2, uintptr_t parm3,
|
||||
uintptr_t parm4)
|
||||
{
|
||||
return sys_call6(nbr, parm1, parm2, parm3, parm4, 0, 0);
|
||||
}
|
||||
|
||||
/* SWI with SYS_ call number and five parameters */
|
||||
|
||||
static inline uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1,
|
||||
uintptr_t parm2, uintptr_t parm3,
|
||||
uintptr_t parm4, uintptr_t parm5)
|
||||
{
|
||||
return sys_call6(nbr, parm1, parm2, parm3, parm4, parm5, 0);
|
||||
}
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_X86_INCLUDE_I486_SYSCALL_H */
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/************************************************************************
|
||||
* arch/x86/include/i486/types.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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
|
||||
************************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
* Pre-processor 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 signed char _int8_t;
|
||||
typedef unsigned char _uint8_t;
|
||||
|
||||
typedef signed short _int16_t;
|
||||
typedef unsigned short _uint16_t;
|
||||
|
||||
typedef signed int _int32_t;
|
||||
typedef unsigned int _uint32_t;
|
||||
|
||||
typedef signed long long _int64_t;
|
||||
typedef unsigned long long _uint64_t;
|
||||
#define __INT64_DEFINED
|
||||
|
||||
/* A pointer is 4 bytes */
|
||||
|
||||
typedef signed 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 */
|
||||
@@ -1,87 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/io.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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_IO_H
|
||||
#define __ARCH_X86_INCLUDE_IO_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* Include architecture-specific IO definitions (These are probably common
|
||||
* across all architectures, but this gives a little bit of flexibility).
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_I486
|
||||
# include <arch/i486/io.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_X86_INCLUDE_IO_H */
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/irq.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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_IRQ_H
|
||||
#define __ARCH_X86_INCLUDE_IRQ_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* Include NuttX-specific IRQ definitions */
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
/* Include chip-specific IRQ definitions (including IRQ numbers) */
|
||||
|
||||
#include <arch/chip/irq.h>
|
||||
|
||||
/* Include architecture-specific IRQ definitions (including register save
|
||||
* structure and irqsave()/irqrestore() macros).
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_I486
|
||||
# include <arch/i486/irq.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_X86_INCLUDE_IRQ_H */
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/limits.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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_LIMITS_H
|
||||
#define __ARCH_X86_INCLUDE_LIMITS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* Include architecture-specific limits */
|
||||
|
||||
#ifdef CONFIG_ARCH_I486
|
||||
# include <arch/i486/limits.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __ARCH_X86_INCLUDE_LIMITS_H */
|
||||
@@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/qemu/arch.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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_QEMU_ARCH_H
|
||||
#define __ARCH_X86_INCLUDE_QEMU_ARCH_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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_QEMU_ARCH_H */
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/qemu/irq.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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_QEMU_IRQ_H
|
||||
#define __ARCH_X86_INCLUDE_QEMU_IRQ_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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_QEMU_IRQ_H */
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/syscall.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 include/syscall.h or include/sys/sycall.h
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_X86_INCLUDE_SYSCALL_H
|
||||
#define __ARCH_X86_INCLUDE_SYSCALL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* Include x86 architecture-specific syscall macros */
|
||||
|
||||
#ifdef CONFIG_ARCH_I486
|
||||
# include <arch/i486/syscall.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_X86_INCLUDE_SYSCALL_H */
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/include/types.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 sys/types.h
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_X86_INCLUDE_TYPES_H
|
||||
#define __ARCH_X86_INCLUDE_TYPES_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* Include architecture-specific limits */
|
||||
|
||||
#ifdef CONFIG_ARCH_I486
|
||||
# include <arch/i486/types.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __ARCH_X86_INCLUDE_TYPES_H */
|
||||
@@ -1,4 +0,0 @@
|
||||
/chip
|
||||
/board
|
||||
/.depend
|
||||
/Make.dep
|
||||
@@ -1,186 +0,0 @@
|
||||
############################################################################
|
||||
# arch/x86/src/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
-include chip/Make.defs
|
||||
|
||||
ifeq ($(CONFIG_ARCH_I486),y)
|
||||
ARCH_SUBDIR = i486
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src
|
||||
NUTTX = $(TOPDIR)\nuttx$(EXEEXT)
|
||||
CFLAGS += -I$(ARCH_SRCDIR)\chip
|
||||
CFLAGS += -I$(ARCH_SRCDIR)\common
|
||||
CFLAGS += -I$(ARCH_SRCDIR)\$(ARCH_SUBDIR)
|
||||
CFLAGS += -I$(TOPDIR)\sched
|
||||
else
|
||||
ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
|
||||
ifeq ($(WINTOOL),y)
|
||||
NUTTX = "${shell cygpath -w $(TOPDIR)/nuttx$(EXEEXT)}"
|
||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}"
|
||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/common}"
|
||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/$(ARCH_SUBDIR)}"
|
||||
CFLAGS += -I "${shell cygpath -w $(TOPDIR)/sched}"
|
||||
else
|
||||
NUTTX = $(TOPDIR)/nuttx$(EXEEXT)
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/chip
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/common
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/$(ARCH_SUBDIR)
|
||||
CFLAGS += -I$(TOPDIR)/sched
|
||||
endif
|
||||
endif
|
||||
|
||||
HEAD_OBJ = $(HEAD_ASRC:.S=$(OBJEXT))
|
||||
STARTUP_OBJS ?= $(HEAD_OBJ)
|
||||
|
||||
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS)
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
LDFLAGS += $(ARCHSCRIPT)
|
||||
EXTRA_LIBS ?=
|
||||
LINKLIBS ?=
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BOARDMAKE = $(if $(wildcard .\board\Makefile),y,)
|
||||
LIBPATHS += -L"$(TOPDIR)\lib"
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
LIBPATHS += -L"$(TOPDIR)\arch\$(CONFIG_ARCH)\src\board"
|
||||
endif
|
||||
|
||||
else
|
||||
BOARDMAKE = $(if $(wildcard ./board/Makefile),y,)
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
LIBPATHS += -L"${shell cygpath -w "$(TOPDIR)/lib"}"
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
LIBPATHS += -L"${shell cygpath -w "$(TOPDIR)/arch/$(CONFIG_ARCH)/src/board"}"
|
||||
endif
|
||||
|
||||
else
|
||||
LIBPATHS += -L"$(TOPDIR)/lib"
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
LIBPATHS += -L"$(TOPDIR)/arch/$(CONFIG_ARCH)/src/board"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS)))
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
LDLIBS += -lboard
|
||||
endif
|
||||
|
||||
LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"
|
||||
|
||||
ifeq ($(HOSTOS),FreeBSD)
|
||||
HOST_ARCH = ${shell uname -m 2>/dev/null || echo "Other"}
|
||||
ifeq ($(HOST_ARCH),amd64)
|
||||
LDFLAGS += -melf_i386
|
||||
LIBGCC = "/usr/lib32/libgcc.a"
|
||||
endif
|
||||
endif
|
||||
|
||||
VPATH = chip:common:$(ARCH_SUBDIR)
|
||||
|
||||
all: $(HEAD_OBJ) libarch$(LIBEXT)
|
||||
|
||||
.PHONY: board/libboard$(LIBEXT)
|
||||
|
||||
$(AOBJS) $(HEAD_OBJ): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
libarch$(LIBEXT): $(OBJS)
|
||||
$(call ARCHIVE, $@, $(OBJS))
|
||||
|
||||
board/libboard$(LIBEXT):
|
||||
$(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" libboard$(LIBEXT) EXTRADEFINES=$(EXTRADEFINES)
|
||||
|
||||
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT)
|
||||
@echo "LD: nuttx$(EXEEXT)"
|
||||
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX)$(EXEEXT) $(HEAD_OBJ) $(EXTRA_OBJS) \
|
||||
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
|
||||
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
$(Q) $(NM) $(NUTTX)$(EXEEXT) | \
|
||||
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
|
||||
sort > $(TOPDIR)/System.map
|
||||
endif
|
||||
|
||||
# This is part of the top-level export target
|
||||
|
||||
export_startup: board/libboard$(LIBEXT) $(STARTUP_OBJS)
|
||||
$(Q) if [ -d "$(EXPORT_DIR)/startup" ]; then \
|
||||
cp -f $(STARTUP_OBJS) "$(EXPORT_DIR)/startup"; \
|
||||
else \
|
||||
echo "$(EXPORT_DIR)/startup does not exist"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Dependencies
|
||||
|
||||
.depend: Makefile chip/Make.defs $(SRCS)
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
$(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" depend
|
||||
endif
|
||||
$(Q) $(MKDEP) --dep-path chip --dep-path common --dep-path $(ARCH_SUBDIR) \
|
||||
"$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
$(Q) touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
$(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" clean
|
||||
endif
|
||||
$(call DELFILE, libarch$(LIBEXT))
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
$(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" distclean
|
||||
endif
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
@@ -1,31 +0,0 @@
|
||||
arch/x86/src/README.txt
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This directory holds x86-specific source files. All x86 source reside in
|
||||
lower-level common, chip-specific, and architecture-specific directories.
|
||||
|
||||
common/ Directory
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
This directory holds source files common to all x86 architectures.
|
||||
|
||||
Architecture-Specific Directories
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Architecture-specific directories hold common source files shared for by
|
||||
implementations of specific x86 architectures.
|
||||
|
||||
i486
|
||||
This directory holds logic appropriate for any instantiation of the 32-bit
|
||||
i486 architecture.
|
||||
|
||||
Chip-Specific directories
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The same x86 architecture may be realized in different chip implementations.
|
||||
For SoC chips, in particular, on-chip devices and differing interrupt
|
||||
structures may require special, chip-specific definitions in these chip-
|
||||
specific directories.
|
||||
|
||||
qemu
|
||||
This is the implementation of NuttX on the QEMU x86 simulation.
|
||||
@@ -1,9 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if ARCH_X86
|
||||
comment "Common Configuration Options"
|
||||
|
||||
endif
|
||||
@@ -1,88 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_allocateheap.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_allocate_heap
|
||||
*
|
||||
* Description:
|
||||
* This function will be called to dynamically set aside the heap region.
|
||||
*
|
||||
* For the kernel build (CONFIG_BUILD_KERNEL=y) with both kernel- and
|
||||
* user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function provides the
|
||||
* size of the unprotected, user-space heap.
|
||||
*
|
||||
* If a protected kernel-space heap is provided, the kernel heap must be
|
||||
* allocated (and protected) by an analogous up_allocate_kheap().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
|
||||
{
|
||||
board_led_on(LED_HEAPALLOCATE);
|
||||
*heap_start = (FAR void*)g_idle_topstack;
|
||||
*heap_size = CONFIG_RAM_END - g_idle_topstack;
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_arch.h
|
||||
*
|
||||
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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_SRC_COMMON_UP_ARCH_H
|
||||
#define ___ARCH_X86_SRC_COMMON_UP_ARCH_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#include <arch/io.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
# define getreg8(p) inb(p)
|
||||
# define putreg8(v,p) outb(v,p)
|
||||
# define getreg16(p) inw(p)
|
||||
# define putreg16(v,p) outw(v,p)
|
||||
# define getreg32(p) inl(p)
|
||||
# define putreg32(v,p) outl(v,p)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Atomic modification of registers */
|
||||
|
||||
void modifyreg8(unsigned int addr, uint8_t clearbits, uint8_t setbits);
|
||||
void modifyreg16(unsigned int addr, uint16_t clearbits, uint16_t setbits);
|
||||
void modifyreg32(unsigned int addr, uint32_t clearbits, uint32_t setbits);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* ___ARCH_X86_SRC_COMMON_UP_ARCH_H */
|
||||
@@ -1,308 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_assert.c
|
||||
*
|
||||
* Copyright (C) 2011-2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/* Output debug info if stack dump is selected -- even if debug is not
|
||||
* selected.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
# undef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_VERBOSE
|
||||
# define CONFIG_DEBUG 1
|
||||
# define CONFIG_DEBUG_VERBOSE 1
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/arch.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "sched/sched.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* USB trace dumping */
|
||||
|
||||
#ifndef CONFIG_USBDEV_TRACE
|
||||
# undef CONFIG_ARCH_USBDUMP
|
||||
#endif
|
||||
|
||||
/* The following is just intended to keep some ugliness out of the mainline
|
||||
* code. We are going to print the task name if:
|
||||
*
|
||||
* CONFIG_TASK_NAME_SIZE > 0 && <-- The task has a name
|
||||
* (defined(CONFIG_DEBUG) || <-- And the debug is enabled (lldbg used)
|
||||
* defined(CONFIG_ARCH_STACKDUMP) <-- Or lowsyslog() is used
|
||||
*/
|
||||
|
||||
#undef CONFIG_PRINT_TASKNAME
|
||||
#if CONFIG_TASK_NAME_SIZE > 0 && (defined(CONFIG_DEBUG) || defined(CONFIG_ARCH_STACKDUMP))
|
||||
# define CONFIG_PRINT_TASKNAME 1
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_stackdump
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_stackdump(uint32_t sp, uint32_t stack_base)
|
||||
{
|
||||
uint32_t stack ;
|
||||
|
||||
for (stack = sp & ~0x1f; stack < stack_base; stack += 32)
|
||||
{
|
||||
uint32_t *ptr = (uint32_t*)stack;
|
||||
lldbg("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
stack, ptr[0], ptr[1], ptr[2], ptr[3],
|
||||
ptr[4], ptr[5], ptr[6], ptr[7]);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define up_stackdump()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: assert_tracecallback
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_USBDUMP
|
||||
static int usbtrace_syslog(FAR const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
/* Let vsyslog do the real work */
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = lowvsyslog(LOG_INFO, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
{
|
||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_dumpstate
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
uint32_t istackbase;
|
||||
uint32_t istacksize;
|
||||
#endif
|
||||
|
||||
/* Get the limits on the user stack memory */
|
||||
|
||||
if (rtcb->pid == 0)
|
||||
{
|
||||
ustackbase = g_idle_topstack - 4;
|
||||
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
|
||||
ustacksize = (uint32_t)rtcb->adj_stack_size;
|
||||
}
|
||||
|
||||
/* Get the limits on the interrupt stack memory */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
istackbase = (uint32_t)&g_intstackbase;
|
||||
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4;
|
||||
|
||||
/* Show interrupt stack info */
|
||||
|
||||
lldbg("sp: %08x\n", sp);
|
||||
lldbg("IRQ stack:\n");
|
||||
lldbg(" base: %08x\n", istackbase);
|
||||
lldbg(" size: %08x\n", istacksize);
|
||||
|
||||
/* Does the current stack pointer lie within the interrupt
|
||||
* stack?
|
||||
*/
|
||||
|
||||
if (sp <= istackbase && sp > istackbase - istacksize)
|
||||
{
|
||||
/* Yes.. dump the interrupt stack */
|
||||
|
||||
up_stackdump(sp, istackbase);
|
||||
|
||||
/* Extract the user stack pointer which should lie
|
||||
* at the base of the interrupt stack.
|
||||
*/
|
||||
|
||||
sp = g_intstackbase;
|
||||
lldbg("sp: %08x\n", sp);
|
||||
}
|
||||
|
||||
/* Show user stack info */
|
||||
|
||||
lldbg("User stack:\n");
|
||||
lldbg(" base: %08x\n", ustackbase);
|
||||
lldbg(" size: %08x\n", ustacksize);
|
||||
#else
|
||||
lldbg("sp: %08x\n", sp);
|
||||
lldbg("stack base: %08x\n", ustackbase);
|
||||
lldbg("stack size: %08x\n", ustacksize);
|
||||
#endif
|
||||
|
||||
/* Dump the user stack if the stack pointer lies within the allocated user
|
||||
* stack memory.
|
||||
*/
|
||||
|
||||
if (sp > ustackbase || sp <= ustackbase - ustacksize)
|
||||
{
|
||||
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
|
||||
lldbg("ERROR: Stack pointer is not within allocated stack\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
up_stackdump(sp, ustackbase);
|
||||
}
|
||||
|
||||
/* Then dump the registers (if available) */
|
||||
|
||||
if (current_regs != NULL)
|
||||
{
|
||||
up_registerdump((uint32_t*)current_regs);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_USBDUMP
|
||||
/* Dump USB trace data */
|
||||
|
||||
(void)usbtrace_enumerate(assert_tracecallback, NULL);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
# define up_dumpstate()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: _up_assert
|
||||
****************************************************************************/
|
||||
|
||||
static void _up_assert(int errorcode) noreturn_function;
|
||||
static void _up_assert(int errorcode)
|
||||
{
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (current_regs || ((struct tcb_s*)g_readytorun.head)->pid == 0)
|
||||
{
|
||||
(void)irqsave();
|
||||
for (;;)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
board_led_on(LED_PANIC);
|
||||
up_mdelay(250);
|
||||
board_led_off(LED_PANIC);
|
||||
up_mdelay(250);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exit(errorcode);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_assert
|
||||
****************************************************************************/
|
||||
|
||||
void up_assert(const uint8_t *filename, int lineno)
|
||||
{
|
||||
#ifdef CONFIG_PRINT_TASKNAME
|
||||
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
#endif
|
||||
|
||||
board_led_on(LED_ASSERTION);
|
||||
|
||||
#ifdef CONFIG_PRINT_TASKNAME
|
||||
lldbg("Assertion failed at file:%s line: %d task: %s\n",
|
||||
filename, lineno, rtcb->name);
|
||||
#else
|
||||
lldbg("Assertion failed at file:%s line: %d\n",
|
||||
filename, lineno);
|
||||
#endif
|
||||
|
||||
up_dumpstate();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), g_readytorun.head, filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_blocktask.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_block_task
|
||||
*
|
||||
* Description:
|
||||
* The currently executing task at the head of the ready to run list must
|
||||
* be stopped. Save its context and move it to the inactive list specified
|
||||
* by task_state.
|
||||
*
|
||||
* Inputs:
|
||||
* tcb: Refers to a task in the ready-to-run list (normally the task at the
|
||||
* head of the list). It most be stopped, its context saved and moved
|
||||
* into one of the waiting task lists. It it was the task at the head
|
||||
* of the ready-to-run list, then a context to the new ready to run task
|
||||
* must be performed.
|
||||
* task_state: Specifies which waiting task list should be
|
||||
* hold the blocked task TCB.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_block_task(struct tcb_s *tcb, tstate_t task_state)
|
||||
{
|
||||
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
bool switch_needed;
|
||||
|
||||
/* Verify that the context switch can be performed */
|
||||
|
||||
ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) &&
|
||||
(tcb->task_state <= LAST_READY_TO_RUN_STATE));
|
||||
|
||||
/* Remove the tcb task from the ready-to-run list. If we
|
||||
* are blocking the task at the head of the task list (the
|
||||
* most likely case), then a context switch to the next
|
||||
* ready-to-run task is needed. In this case, it should
|
||||
* also be true that rtcb == tcb.
|
||||
*/
|
||||
|
||||
switch_needed = sched_removereadytorun(tcb);
|
||||
|
||||
/* Add the task to the specified blocked task list */
|
||||
|
||||
sched_addblocked(tcb, (tstate_t)task_state);
|
||||
|
||||
/* If there are any pending tasks, then add them to the g_readytorun
|
||||
* task list now
|
||||
*/
|
||||
|
||||
if (g_pendingtasks.head)
|
||||
{
|
||||
switch_needed |= sched_mergepending();
|
||||
}
|
||||
|
||||
/* Now, perform the context switch if one is needed */
|
||||
|
||||
if (switch_needed)
|
||||
{
|
||||
/* Are we in an interrupt handler? */
|
||||
|
||||
if (current_regs)
|
||||
{
|
||||
/* Yes, then we have to do things differently.
|
||||
* Just copy the current_regs into the OLD rtcb.
|
||||
*/
|
||||
|
||||
up_savestate(rtcb->xcp.regs);
|
||||
|
||||
/* Restore the exception context of the rtcb at the (new) head
|
||||
* of the g_readytorun task list.
|
||||
*/
|
||||
|
||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
|
||||
/* Then switch contexts. Any necessary address environment
|
||||
* changes will be made when the interrupt returns.
|
||||
*/
|
||||
|
||||
up_restorestate(rtcb->xcp.regs);
|
||||
}
|
||||
|
||||
/* Copy the user C context into the TCB at the (old) head of the
|
||||
* g_readytorun Task list. if up_saveusercontext returns a non-zero
|
||||
* value, then this is really the previously running task restarting!
|
||||
*/
|
||||
|
||||
else if (!up_saveusercontext(rtcb->xcp.regs))
|
||||
{
|
||||
/* Restore the exception context of the rtcb at the (new) head
|
||||
* of the g_readytorun task list.
|
||||
*/
|
||||
|
||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Make sure that the address environment for the previously
|
||||
* running task is closed down gracefully (data caches dump,
|
||||
* MMU flushed) and set up the address environment for the new
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(rtcb);
|
||||
#endif
|
||||
/* Then switch contexts */
|
||||
|
||||
up_fullcontextrestore(rtcb->xcp.regs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_copystate.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_undefinedinsn
|
||||
****************************************************************************/
|
||||
|
||||
/* A little faster than most memcpy's */
|
||||
|
||||
void up_copystate(uint32_t *dest, uint32_t *src)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* In the current ARM model, the state is always copied to and from the
|
||||
* stack and TCB.
|
||||
*/
|
||||
|
||||
for (i = 0; i < XCPTCONTEXT_REGS; i++)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/up_elf.c
|
||||
*
|
||||
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <elf32.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define R_386_32 1
|
||||
#define R_386_PC32 2
|
||||
|
||||
#define ELF_BITS 32
|
||||
#define ELF_ARCH EM_386
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_checkarch
|
||||
*
|
||||
* Description:
|
||||
* Given the ELF header in 'hdr', verify that the ELF file is appropriate
|
||||
* for the current, configured architecture. Every architecture that uses
|
||||
* the ELF loader must provide this function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* hdr - The ELF header read from the ELF file.
|
||||
*
|
||||
* Returned Value:
|
||||
* True if the architecture supports this ELF file.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool up_checkarch(FAR const Elf32_Ehdr *hdr)
|
||||
{
|
||||
return hdr->e_machine == EM_386 || hdr->e_machine == EM_486;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_relocate and up_relocateadd
|
||||
*
|
||||
* Description:
|
||||
* Perform on architecture-specific ELF relocation. Every architecture
|
||||
* that uses the ELF loader must provide this function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* rel - The relocation type
|
||||
* sym - The ELF symbol structure containing the fully resolved value.
|
||||
* There are a few relocation types for a few architectures that do
|
||||
* not require symbol information. For those, this value will be
|
||||
* NULL. Implementations of these functions must be able to handle
|
||||
* that case.
|
||||
* addr - The address that requires the relocation.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) if the relocation was successful. Otherwise, a negated errno
|
||||
* value indicating the cause of the relocation failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
|
||||
uintptr_t addr)
|
||||
{
|
||||
FAR uint32_t *ptr = (FAR uint32_t *)addr;
|
||||
|
||||
/* All relocations depend upon having valid symbol information. */
|
||||
|
||||
if (sym == NULL)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Handle the relocation by relocation type */
|
||||
|
||||
switch (ELF32_R_TYPE(rel->r_info))
|
||||
{
|
||||
case R_386_32:
|
||||
*ptr += sym->st_value;
|
||||
break;
|
||||
|
||||
case R_386_PC32:
|
||||
*ptr += sym->st_value - (uint32_t)ptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
|
||||
uintptr_t addr)
|
||||
{
|
||||
bdbg("Not supported\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
/****************************************************************************
|
||||
* common/up_exit.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#ifdef CONFIG_DUMP_ON_EXIT
|
||||
#include <nuttx/fs/fs.h>
|
||||
#endif
|
||||
|
||||
#include "task/task.h"
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: _up_dumponexit
|
||||
*
|
||||
* Description:
|
||||
* Dump the state of all tasks whenever on task exits. This is debug
|
||||
* instrumentation that was added to check file-related reference counting
|
||||
* but could be useful again sometime in the future.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
sdbg(" TCB=%p name=%s pid=%d\n", tcb, tcb->argv[0], tcb->pid);
|
||||
sdbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
sdbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_fd >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
sdbg(" fd=%d nbytes=%d\n",
|
||||
filep->fs_fd,
|
||||
filep->fs_bufpos - filep->fs_bufstart);
|
||||
#else
|
||||
sdbg(" fd=%d\n", filep->fs_fd);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: _exit
|
||||
*
|
||||
* Description:
|
||||
* This function causes the currently executing task to cease to exist.
|
||||
* This is a special case of task_delete() where the task to be deleted is
|
||||
* the currently executing task. It is more complex because a context
|
||||
* switch must be perform to the next ready to run task.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void _exit(int status)
|
||||
{
|
||||
struct tcb_s* tcb;
|
||||
|
||||
/* Disable interrupts. They will be restored when the next
|
||||
* task is started.
|
||||
*/
|
||||
|
||||
(void)irqsave();
|
||||
|
||||
slldbg("TCB=%p exiting\n", g_readytorun.head);
|
||||
|
||||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
slldbg("Other tasks:\n");
|
||||
sched_foreach(_up_dumponexit, NULL);
|
||||
#endif
|
||||
|
||||
/* Destroy the task at the head of the ready to run list. */
|
||||
|
||||
(void)task_exit();
|
||||
|
||||
/* Now, perform the context switch to the new ready-to-run task at the
|
||||
* head of the list.
|
||||
*/
|
||||
|
||||
tcb = (struct tcb_s*)g_readytorun.head;
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Make sure that the address environment for the previously running
|
||||
* task is closed down gracefully (data caches dump, MMU flushed) and
|
||||
* set up the address environment for the new thread at the head of
|
||||
* the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(tcb);
|
||||
#endif
|
||||
|
||||
/* Then switch contexts */
|
||||
|
||||
up_fullcontextrestore(tcb->xcp.regs);
|
||||
}
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_initialize.c
|
||||
*
|
||||
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_calibratedelay
|
||||
*
|
||||
* Description:
|
||||
* Delay loops are provided for short timing loops. This function, if
|
||||
* enabled, will just wait for 100 seconds. Using a stopwatch, you can
|
||||
* can then determine if the timing loops are properly calibrated.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARCH_CALIBRATION) && defined(CONFIG_DEBUG)
|
||||
static void up_calibratedelay(void)
|
||||
{
|
||||
int i;
|
||||
lldbg("Beginning 100s delay\n");
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
up_mdelay(1000);
|
||||
}
|
||||
lldbg("End 100s delay\n");
|
||||
}
|
||||
#else
|
||||
# define up_calibratedelay()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_initialize
|
||||
*
|
||||
* Description:
|
||||
* up_initialize will be called once during OS initialization after the
|
||||
* basic OS services have been initialized. The architecture specific
|
||||
* details of initializing the OS will be handled here. Such things as
|
||||
* setting up interrupt service routines, starting the clock, and
|
||||
* registering device drivers are some of the things that are different
|
||||
* for each processor and hardware platform.
|
||||
*
|
||||
* up_initialize is called after the OS initialized but before the user
|
||||
* initialization logic has been started and before the libraries have
|
||||
* been initialized. OS services and driver services are available.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_initialize(void)
|
||||
{
|
||||
/* Initialize global variables */
|
||||
|
||||
current_regs = NULL;
|
||||
|
||||
/* Calibrate the timing loop */
|
||||
|
||||
up_calibratedelay();
|
||||
|
||||
/* Add any extra memory fragments to the memory manager */
|
||||
|
||||
up_addregion();
|
||||
|
||||
/* Initialize the interrupt subsystem */
|
||||
|
||||
up_irqinitialize();
|
||||
|
||||
/* Initialize the DMA subsystem if the weak function up_dmainitialize has been
|
||||
* brought into the build
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_DMA
|
||||
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
if (up_dmainitialize)
|
||||
#endif
|
||||
{
|
||||
up_dmainitialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize the system timer interrupt */
|
||||
|
||||
#if !defined(CONFIG_SUPPRESS_INTERRUPTS) && !defined(CONFIG_SUPPRESS_TIMER_INTS)
|
||||
up_timer_initialize();
|
||||
#endif
|
||||
|
||||
/* Register devices */
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
|
||||
#if defined(CONFIG_DEV_NULL)
|
||||
devnull_register(); /* Standard /dev/null */
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_DEV_ZERO)
|
||||
devzero_register(); /* Standard /dev/zero */
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NFILE_DESCRIPTORS */
|
||||
|
||||
/* Initialize the serial device driver */
|
||||
|
||||
#ifdef USE_SERIALDRIVER
|
||||
up_serialinit();
|
||||
#endif
|
||||
|
||||
/* Initialize the console device driver (if it is other than the standard
|
||||
* serial driver).
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
||||
/* Initialize the system logging device */
|
||||
|
||||
#ifdef CONFIG_SYSLOG_CHAR
|
||||
syslog_initialize();
|
||||
#endif
|
||||
#ifdef CONFIG_RAMLOG_SYSLOG
|
||||
ramlog_sysloginit();
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETDEV_LATEINIT
|
||||
/* Initialize the network */
|
||||
|
||||
up_netinitialize();
|
||||
#endif
|
||||
|
||||
/* Initialize USB -- device and/or host */
|
||||
|
||||
up_usbinitialize();
|
||||
board_led_on(LED_IRQSENABLED);
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_internal.h
|
||||
*
|
||||
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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_SRC_COMMON_UP_INTERNAL_H
|
||||
#define __ARCH_X86_SRC_COMMON_UP_INTERNAL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <nuttx/compiler.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Bring-up debug configurations. These are here (vs defconfig) because
|
||||
* these should only be controlled during low level board bring-up and not
|
||||
* part of normal platform configuration.
|
||||
*/
|
||||
|
||||
#undef CONFIG_SUPPRESS_INTERRUPTS /* DEFINED: Do not enable interrupts */
|
||||
#undef CONFIG_SUPPRESS_TIMER_INTS /* DEFINED: No timer */
|
||||
#undef CONFIG_SUPPRESS_SERIAL_INTS /* DEFINED: Console will poll */
|
||||
#undef CONFIG_SUPPRESS_UART_CONFIG /* DEFINED: Do not reconfig UART */
|
||||
#undef CONFIG_DUMP_ON_EXIT /* DEFINED: Dump task state on exit */
|
||||
|
||||
/* Determine which (if any) console driver to use. If a console is enabled
|
||||
* and no other console device is specified, then a serial console is
|
||||
* assumed.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_DEV_CONSOLE) || CONFIG_NFILE_DESCRIPTORS <= 0
|
||||
# undef USE_SERIALDRIVER
|
||||
# undef USE_EARLYSERIALINIT
|
||||
# undef CONFIG_DEV_LOWCONSOLE
|
||||
# undef CONFIG_RAMLOG_CONSOLE
|
||||
#else
|
||||
# if defined(CONFIG_RAMLOG_CONSOLE)
|
||||
# undef USE_SERIALDRIVER
|
||||
# undef USE_EARLYSERIALINIT
|
||||
# undef CONFIG_DEV_LOWCONSOLE
|
||||
# elif defined(CONFIG_DEV_LOWCONSOLE)
|
||||
# undef USE_SERIALDRIVER
|
||||
# undef USE_EARLYSERIALINIT
|
||||
# else
|
||||
# define USE_SERIALDRIVER 1
|
||||
# define USE_EARLYSERIALINIT 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If some other device is used as the console, then the serial driver may
|
||||
* still be needed. Let's assume that if the upper half serial driver is
|
||||
* built, then the lower half will also be needed. There is no need for
|
||||
* the early serial initialization in this case.
|
||||
*/
|
||||
|
||||
#if !defined(USE_SERIALDRIVER) && defined(CONFIG_STANDARD_SERIAL)
|
||||
# define USE_SERIALDRIVER 1
|
||||
#endif
|
||||
|
||||
/* Determine which device to use as the system logging device */
|
||||
|
||||
#ifndef CONFIG_SYSLOG
|
||||
# undef CONFIG_SYSLOG_CHAR
|
||||
# undef CONFIG_RAMLOG_SYSLOG
|
||||
#endif
|
||||
|
||||
/* Check if an interrupt stack size is configured */
|
||||
|
||||
#ifndef CONFIG_ARCH_INTERRUPTSTACK
|
||||
# define CONFIG_ARCH_INTERRUPTSTACK 0
|
||||
#endif
|
||||
|
||||
/* Macros to handle saving and restore interrupt state. In the current
|
||||
* model, the state is copied from the stack to the TCB, but only a
|
||||
* referenced is passed to get the state from the TCB.
|
||||
*/
|
||||
|
||||
#define up_restorestate(regs) (current_regs = regs)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
typedef void (*up_vector_t)(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
/* This holds a references to the current interrupt level register storage
|
||||
* structure. If is non-NULL only during interrupt processing.
|
||||
*/
|
||||
|
||||
extern volatile uint32_t *current_regs;
|
||||
|
||||
/* This is the beginning of heap as provided from up_head.S. This is the first
|
||||
* address in DRAM after the loaded program+bss+idle stack. The end of the
|
||||
* heap is CONFIG_RAM_END
|
||||
*/
|
||||
|
||||
extern uint32_t g_idle_topstack;
|
||||
|
||||
/* Address of the saved user stack pointer */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
extern uint32_t g_intstackbase;
|
||||
#endif
|
||||
|
||||
/* These 'addresses' of these values are setup by the linker script. They are
|
||||
* not actual uint32_t storage locations! They are only used meaningfully in the
|
||||
* following way:
|
||||
*
|
||||
* - The linker script defines, for example, the symbol_sdata.
|
||||
* - The declareion extern uint32_t _sdata; makes C happy. C will believe
|
||||
* that the value _sdata is the address of a uint32_t variable _data (it is
|
||||
* not!).
|
||||
* - We can recoved the linker value then by simply taking the address of
|
||||
* of _data. like: uint32_t *pdata = &_sdata;
|
||||
*/
|
||||
|
||||
extern uint32_t _stext; /* Start of .text */
|
||||
extern uint32_t _etext; /* End_1 of .text + .rodata */
|
||||
extern const uint32_t _eronly; /* End+1 of read only section (.text + .rodata) */
|
||||
extern uint32_t _sdata; /* Start of .data */
|
||||
extern uint32_t _edata; /* End+1 of .data */
|
||||
extern uint32_t _sbss; /* Start of .bss */
|
||||
extern uint32_t _ebss; /* End+1 of .bss */
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x86_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* This function must be provided by the board-specific logic in the
|
||||
* directory configs/<board-name>/src/.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void x86_boardinitialize(void);
|
||||
|
||||
/* Defined in files with the same name as the function */
|
||||
|
||||
void up_boot(void);
|
||||
void up_copystate(uint32_t *dest, uint32_t *src);
|
||||
void up_savestate(uint32_t *regs);
|
||||
void up_decodeirq(uint32_t *regs);
|
||||
void up_irqinitialize(void);
|
||||
#ifdef CONFIG_ARCH_DMA
|
||||
void weak_function up_dmainitialize(void);
|
||||
#endif
|
||||
int up_saveusercontext(uint32_t *saveregs);
|
||||
void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
|
||||
void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs);
|
||||
void up_sigdeliver(void);
|
||||
void up_lowputc(char ch);
|
||||
void up_puts(const char *str);
|
||||
void up_lowputs(const char *str);
|
||||
|
||||
void up_syscall(uint32_t *regs);
|
||||
void up_registerdump(uint32_t *regs);
|
||||
|
||||
/* Defined in up_allocateheap.c */
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
void up_addregion(void);
|
||||
#else
|
||||
# define up_addregion()
|
||||
#endif
|
||||
|
||||
/* Defined in up_serial.c */
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
void up_earlyserialinit(void);
|
||||
void up_serialinit(void);
|
||||
#else
|
||||
# define up_earlyserialinit()
|
||||
# define up_serialinit()
|
||||
#endif
|
||||
|
||||
/* Defined in drivers/lowconsole.c */
|
||||
|
||||
#ifdef CONFIG_DEV_LOWCONSOLE
|
||||
void lowconsole_init(void);
|
||||
#else
|
||||
# define lowconsole_init()
|
||||
#endif
|
||||
|
||||
/* Defined in up_watchdog.c */
|
||||
|
||||
void up_wdtinit(void);
|
||||
|
||||
/* Defined in up_timerisr.c */
|
||||
|
||||
void up_timer_initialize(void);
|
||||
|
||||
/* Defined in board/up_network.c */
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
void up_netinitialize(void);
|
||||
#else
|
||||
# define up_netinitialize()
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBDEV
|
||||
void up_usbinitialize(void);
|
||||
void up_usbuninitialize(void);
|
||||
#else
|
||||
# define up_usbinitialize()
|
||||
# define up_usbuninitialize()
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ARCH_X86_SRC_COMMON_UP_INTERNAL_H */
|
||||
@@ -1,72 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_interruptcontext.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_interrupt_context
|
||||
*
|
||||
* Description:
|
||||
* Return true is we are currently executing in the interrupt handler
|
||||
* context.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool up_interrupt_context(void)
|
||||
{
|
||||
return current_regs != NULL;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_lowputs.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_lowputs
|
||||
*
|
||||
* Description:
|
||||
* This is a low-level helper function used to support debug.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_lowputs(const char *str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
up_lowputc(*str++);
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_mdelay.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_mdelay
|
||||
*
|
||||
* Description:
|
||||
* Delay inline for the requested number of milliseconds.
|
||||
* *** NOT multi-tasking friendly ***
|
||||
*
|
||||
* ASSUMPTIONS:
|
||||
* The setting CONFIG_BOARD_LOOPSPERMSEC has been calibrated
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_mdelay(unsigned int milliseconds)
|
||||
{
|
||||
volatile int i;
|
||||
volatile int j;
|
||||
|
||||
for (i = 0; i < milliseconds; i++)
|
||||
{
|
||||
for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_modifyreg16.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modifyreg16
|
||||
*
|
||||
* Description:
|
||||
* Atomically modify the specified bits in a memory mapped register
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modifyreg16(unsigned int addr, uint16_t clearbits, uint16_t setbits)
|
||||
{
|
||||
irqstate_t flags;
|
||||
uint16_t regval;
|
||||
|
||||
flags = irqsave();
|
||||
regval = getreg16((uint16_t)addr);
|
||||
regval &= ~clearbits;
|
||||
regval |= setbits;
|
||||
putreg16(regval, (uint16_t)addr);
|
||||
irqrestore(flags);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_modifyreg32.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modifyreg32
|
||||
*
|
||||
* Description:
|
||||
* Atomically modify the specified bits in a memory mapped register
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modifyreg32(unsigned int addr, uint32_t clearbits, uint32_t setbits)
|
||||
{
|
||||
irqstate_t flags;
|
||||
uint32_t regval;
|
||||
|
||||
flags = irqsave();
|
||||
regval = getreg32((uint16_t)addr);
|
||||
regval &= ~clearbits;
|
||||
regval |= setbits;
|
||||
putreg32(regval, (uint16_t)addr);
|
||||
irqrestore(flags);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_modifyreg8.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modifyreg8
|
||||
*
|
||||
* Description:
|
||||
* Atomically modify the specified bits in a memory mapped register
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modifyreg8(unsigned int addr, uint8_t clearbits, uint8_t setbits)
|
||||
{
|
||||
irqstate_t flags;
|
||||
uint8_t regval;
|
||||
|
||||
flags = irqsave();
|
||||
regval = getreg8((uint16_t)addr);
|
||||
regval &= ~clearbits;
|
||||
regval |= setbits;
|
||||
putreg8(regval, (uint16_t)addr);
|
||||
irqrestore(flags);
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_puts.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_puts
|
||||
*
|
||||
* Description:
|
||||
* This is a low-level helper function used to support debug.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_puts(const char *str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
up_putc(*str++);
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/arm/up_releasepending.c
|
||||
*
|
||||
* Copyright (C) 2011, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_release_pending
|
||||
*
|
||||
* Description:
|
||||
* Release and ready-to-run tasks that have
|
||||
* collected in the pending task list. This can call a
|
||||
* context switch if a new task is placed at the head of
|
||||
* the ready to run list.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_release_pending(void)
|
||||
{
|
||||
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
|
||||
slldbg("From TCB=%p\n", rtcb);
|
||||
|
||||
/* Merge the g_pendingtasks list into the g_readytorun task list */
|
||||
|
||||
/* sched_lock(); */
|
||||
if (sched_mergepending())
|
||||
{
|
||||
/* The currently active task has changed! We will need to
|
||||
* switch contexts. First check if we are operating in
|
||||
* interrupt context:
|
||||
*/
|
||||
|
||||
if (current_regs)
|
||||
{
|
||||
/* Yes, then we have to do things differently.
|
||||
* Just copy the current_regs into the OLD rtcb.
|
||||
*/
|
||||
|
||||
up_savestate(rtcb->xcp.regs);
|
||||
|
||||
/* Restore the exception context of the rtcb at the (new) head
|
||||
* of the g_readytorun task list.
|
||||
*/
|
||||
|
||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
slldbg("New Active Task TCB=%p\n", rtcb);
|
||||
|
||||
/* Then switch contexts. Any necessary address environment
|
||||
* changes will be made when the interrupt returns.
|
||||
*/
|
||||
|
||||
up_restorestate(rtcb->xcp.regs);
|
||||
}
|
||||
|
||||
/* Copy the exception context into the TCB of the task that
|
||||
* was currently active. if up_saveusercontext returns a non-zero
|
||||
* value, then this is really the previously running task
|
||||
* restarting!
|
||||
*/
|
||||
|
||||
else if (!up_saveusercontext(rtcb->xcp.regs))
|
||||
{
|
||||
/* Restore the exception context of the rtcb at the (new) head
|
||||
* of the g_readytorun task list.
|
||||
*/
|
||||
|
||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
slldbg("New Active Task TCB=%p\n", rtcb);
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Make sure that the address environment for the previously
|
||||
* running task is closed down gracefully (data caches dump,
|
||||
* MMU flushed) and set up the address environment for the new
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(rtcb);
|
||||
#endif
|
||||
/* Then switch contexts */
|
||||
|
||||
up_fullcontextrestore(rtcb->xcp.regs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,199 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/arm/up_reprioritizertr.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_reprioritize_rtr
|
||||
*
|
||||
* Description:
|
||||
* Called when the priority of a running or
|
||||
* ready-to-run task changes and the reprioritization will
|
||||
* cause a context switch. Two cases:
|
||||
*
|
||||
* 1) The priority of the currently running task drops and the next
|
||||
* task in the ready to run list has priority.
|
||||
* 2) An idle, ready to run task's priority has been raised above the
|
||||
* the priority of the current, running task and it now has the
|
||||
* priority.
|
||||
*
|
||||
* Inputs:
|
||||
* tcb: The TCB of the task that has been reprioritized
|
||||
* priority: The new task priority
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
|
||||
{
|
||||
/* Verify that the caller is sane */
|
||||
|
||||
if (tcb->task_state < FIRST_READY_TO_RUN_STATE ||
|
||||
tcb->task_state > LAST_READY_TO_RUN_STATE
|
||||
#if SCHED_PRIORITY_MIN > 0
|
||||
|| priority < SCHED_PRIORITY_MIN
|
||||
#endif
|
||||
#if SCHED_PRIORITY_MAX < UINT8_MAX
|
||||
|| priority > SCHED_PRIORITY_MAX
|
||||
#endif
|
||||
)
|
||||
{
|
||||
PANIC();
|
||||
}
|
||||
else
|
||||
{
|
||||
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
bool switch_needed;
|
||||
|
||||
slldbg("TCB=%p PRI=%d\n", tcb, priority);
|
||||
|
||||
/* Remove the tcb task from the ready-to-run list.
|
||||
* sched_removereadytorun will return true if we just
|
||||
* remove the head of the ready to run list.
|
||||
*/
|
||||
|
||||
switch_needed = sched_removereadytorun(tcb);
|
||||
|
||||
/* Setup up the new task priority */
|
||||
|
||||
tcb->sched_priority = (uint8_t)priority;
|
||||
|
||||
/* Return the task to the specified blocked task list.
|
||||
* sched_addreadytorun will return true if the task was
|
||||
* added to the new list. We will need to perform a context
|
||||
* switch only if the EXCLUSIVE or of the two calls is non-zero
|
||||
* (i.e., one and only one the calls changes the head of the
|
||||
* ready-to-run list).
|
||||
*/
|
||||
|
||||
switch_needed ^= sched_addreadytorun(tcb);
|
||||
|
||||
/* Now, perform the context switch if one is needed */
|
||||
|
||||
if (switch_needed)
|
||||
{
|
||||
/* If we are going to do a context switch, then now is the right
|
||||
* time to add any pending tasks back into the ready-to-run list.
|
||||
* task list now
|
||||
*/
|
||||
|
||||
if (g_pendingtasks.head)
|
||||
{
|
||||
sched_mergepending();
|
||||
}
|
||||
|
||||
/* Are we in an interrupt handler? */
|
||||
|
||||
if (current_regs)
|
||||
{
|
||||
/* Yes, then we have to do things differently.
|
||||
* Just copy the current_regs into the OLD rtcb.
|
||||
*/
|
||||
|
||||
up_savestate(rtcb->xcp.regs);
|
||||
|
||||
/* Restore the exception context of the rtcb at the (new) head
|
||||
* of the g_readytorun task list.
|
||||
*/
|
||||
|
||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
slldbg("New Active Task TCB=%p\n", rtcb);
|
||||
|
||||
/* Then switch contexts. Any necessary address environment
|
||||
* changes will be made when the interrupt returns.
|
||||
*/
|
||||
|
||||
up_restorestate(rtcb->xcp.regs);
|
||||
}
|
||||
|
||||
/* Copy the exception context into the TCB at the (old) head of the
|
||||
* g_readytorun Task list. if up_saveusercontext returns a non-zero
|
||||
* value, then this is really the previously running task restarting!
|
||||
*/
|
||||
|
||||
else if (!up_saveusercontext(rtcb->xcp.regs))
|
||||
{
|
||||
/* Restore the exception context of the rtcb at the (new) head
|
||||
* of the g_readytorun task list.
|
||||
*/
|
||||
|
||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
slldbg("New Active Task TCB=%p\n", rtcb);
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Make sure that the address environment for the previously
|
||||
* running task is closed down gracefully (data caches dump,
|
||||
* MMU flushed) and set up the address environment for the new
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(rtcb);
|
||||
#endif
|
||||
/* Then switch contexts */
|
||||
|
||||
up_fullcontextrestore(rtcb->xcp.regs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_udelay.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CONFIG_BOARD_LOOPSPER100USEC ((CONFIG_BOARD_LOOPSPERMSEC+5)/10)
|
||||
#define CONFIG_BOARD_LOOPSPER10USEC ((CONFIG_BOARD_LOOPSPERMSEC+50)/100)
|
||||
#define CONFIG_BOARD_LOOPSPERUSEC ((CONFIG_BOARD_LOOPSPERMSEC+500)/1000)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_udelay
|
||||
*
|
||||
* Description:
|
||||
* Delay inline for the requested number of microseconds. NOTE: Because
|
||||
* of all of the setup, several microseconds will be lost before the actual
|
||||
* timing looop begins. Thus, the delay will always be a few microseconds
|
||||
* longer than requested.
|
||||
*
|
||||
* *** NOT multi-tasking friendly ***
|
||||
*
|
||||
* ASSUMPTIONS:
|
||||
* The setting CONFIG_BOARD_LOOPSPERMSEC has been calibrated
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_udelay(useconds_t microseconds)
|
||||
{
|
||||
volatile int i;
|
||||
|
||||
/* We'll do this a little at a time because we expect that the
|
||||
* CONFIG_BOARD_LOOPSPERUSEC is very inaccurate during to truncation in
|
||||
* the divisions of its calculation. We'll use the largest values that
|
||||
* we can in order to prevent significant error buildup in the loops.
|
||||
*/
|
||||
|
||||
while (microseconds > 1000)
|
||||
{
|
||||
for (i = 0; i < CONFIG_BOARD_LOOPSPERMSEC; i++)
|
||||
{
|
||||
}
|
||||
microseconds -= 1000;
|
||||
}
|
||||
|
||||
while (microseconds > 100)
|
||||
{
|
||||
for (i = 0; i < CONFIG_BOARD_LOOPSPER100USEC; i++)
|
||||
{
|
||||
}
|
||||
microseconds -= 100;
|
||||
}
|
||||
|
||||
while (microseconds > 10)
|
||||
{
|
||||
for (i = 0; i < CONFIG_BOARD_LOOPSPER10USEC; i++)
|
||||
{
|
||||
}
|
||||
microseconds -= 10;
|
||||
}
|
||||
|
||||
while (microseconds > 0)
|
||||
{
|
||||
for (i = 0; i < CONFIG_BOARD_LOOPSPERUSEC; i++)
|
||||
{
|
||||
}
|
||||
microseconds--;
|
||||
}
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_unblocktask.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "clock/clock.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_unblock_task
|
||||
*
|
||||
* Description:
|
||||
* A task is currently in an inactive task list but has been prepped to
|
||||
* execute. Move the TCB to the ready-to-run list, restore its context,
|
||||
* and start execution.
|
||||
*
|
||||
* Inputs:
|
||||
* tcb: Refers to the tcb to be unblocked. This tcb is in one of the
|
||||
* waiting tasks lists. It must be moved to the ready-to-run list and,
|
||||
* if it is the highest priority ready to run task, executed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_unblock_task(struct tcb_s *tcb)
|
||||
{
|
||||
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
|
||||
/* Verify that the context switch can be performed */
|
||||
|
||||
ASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) &&
|
||||
(tcb->task_state <= LAST_BLOCKED_STATE));
|
||||
|
||||
/* Remove the task from the blocked task list */
|
||||
|
||||
sched_removeblocked(tcb);
|
||||
|
||||
/* Reset its timeslice. This is only meaningful for round
|
||||
* robin tasks but it doesn't here to do it for everything
|
||||
*/
|
||||
|
||||
#if CONFIG_RR_INTERVAL > 0
|
||||
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
|
||||
#endif
|
||||
|
||||
/* Add the task in the correct location in the prioritized
|
||||
* g_readytorun task list
|
||||
*/
|
||||
|
||||
if (sched_addreadytorun(tcb))
|
||||
{
|
||||
/* The currently active task has changed! We need to do
|
||||
* a context switch to the new task.
|
||||
*
|
||||
* Are we in an interrupt handler?
|
||||
*/
|
||||
|
||||
if (current_regs)
|
||||
{
|
||||
/* Yes, then we have to do things differently.
|
||||
* Just copy the current_regs into the OLD rtcb.
|
||||
*/
|
||||
|
||||
up_savestate(rtcb->xcp.regs);
|
||||
|
||||
/* Restore the exception context of the rtcb at the (new) head
|
||||
* of the g_readytorun task list.
|
||||
*/
|
||||
|
||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
|
||||
/* Then switch contexts. Any necessary address environment
|
||||
* changes will be made when the interrupt returns.
|
||||
*/
|
||||
|
||||
up_restorestate(rtcb->xcp.regs);
|
||||
}
|
||||
|
||||
/* We are not in an interrupt handler. Copy the user C context
|
||||
* into the TCB of the task that was previously active. if
|
||||
* up_saveusercontext returns a non-zero value, then this is really the
|
||||
* previously running task restarting!
|
||||
*/
|
||||
|
||||
else if (!up_saveusercontext(rtcb->xcp.regs))
|
||||
{
|
||||
/* Restore the exception context of the new task that is ready to
|
||||
* run (probably tcb). This is the new rtcb at the head of the
|
||||
* g_readytorun task list.
|
||||
*/
|
||||
|
||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Make sure that the address environment for the previously
|
||||
* running task is closed down gracefully (data caches dump,
|
||||
* MMU flushed) and set up the address environment for the new
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(rtcb);
|
||||
#endif
|
||||
/* Then switch contexts */
|
||||
|
||||
up_fullcontextrestore(rtcb->xcp.regs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if ARCH_I486
|
||||
comment "i486 Configuration Options"
|
||||
|
||||
endif
|
||||
@@ -1,96 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/i486/i486_utils.S
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Based on Bran's kernel development tutorials. Rewritten for JamesM's
|
||||
* kernel development tutorials.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
.file "i486_utils.S"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define KSEG 0x10
|
||||
|
||||
/****************************************************************************
|
||||
* Globals
|
||||
****************************************************************************/
|
||||
|
||||
.globl gdt_flush
|
||||
.globl idt_flush
|
||||
|
||||
/****************************************************************************
|
||||
* .text
|
||||
****************************************************************************/
|
||||
|
||||
.text
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gdt_flush
|
||||
****************************************************************************/
|
||||
|
||||
.type gdt_flush, @function
|
||||
gdt_flush:
|
||||
movl %eax, 4(%esp) /* Get the pointer to the GDT, passed as a parameter */
|
||||
lgdt (%eax) /* Load the new GDT pointer */
|
||||
|
||||
mov $KSEG, %ax /* KSEG is the offset in the GDT to our data segment */
|
||||
mov %ax, %ds /* Load all data segment selectors */
|
||||
mov %ax, %es
|
||||
mov %ax, %fs
|
||||
mov %ax, %gs
|
||||
mov %ax, %ss
|
||||
jmp $0x08, $.Lgflush /* 0x08 is the offset to our code segment: Far jump! */
|
||||
.Lgflush:
|
||||
ret
|
||||
.size gdt_flush, . - gdt_flush
|
||||
|
||||
/****************************************************************************
|
||||
* Name: idt_flush
|
||||
****************************************************************************/
|
||||
|
||||
.type idt_flush, @function
|
||||
idt_flush:
|
||||
movl %eax, 4(%esp) /* Get the pointer to the IDT, passed as a parameter */
|
||||
lidt (%eax) /* Load the IDT pointer */
|
||||
ret
|
||||
.size idt_flush, . - idt_flush
|
||||
.end
|
||||
@@ -1,193 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/i486/up_createstack.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_create_stack
|
||||
*
|
||||
* Description:
|
||||
* Allocate a stack for a new thread and setup up stack-related information
|
||||
* in the TCB.
|
||||
*
|
||||
* The following TCB fields must be initialized by this function:
|
||||
*
|
||||
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||
* etc. This value is retained only for debug purposes.
|
||||
* - stack_alloc_ptr: Pointer to allocated stack
|
||||
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||
* the stack pointer.
|
||||
*
|
||||
* Inputs:
|
||||
* - tcb: The TCB of new task
|
||||
* - stack_size: The requested stack size. At least this much
|
||||
* must be allocated.
|
||||
* - ttype: The thread type. This may be one of following (defined in
|
||||
* include/nuttx/sched.h):
|
||||
*
|
||||
* TCB_FLAG_TTYPE_TASK Normal user task
|
||||
* TCB_FLAG_TTYPE_PTHREAD User pthread
|
||||
* TCB_FLAG_TTYPE_KERNEL Kernel thread
|
||||
*
|
||||
* This thread type is normally available in the flags field of the TCB,
|
||||
* however, there are certain contexts where the TCB may not be fully
|
||||
* initialized when up_create_stack is called.
|
||||
*
|
||||
* If CONFIG_BUILD_KERNEL is defined, then this thread type may affect
|
||||
* how the stack is allocated. For example, kernel thread stacks should
|
||||
* be allocated from protected kernel memory. Stacks for user tasks and
|
||||
* threads must come from memory that is accessible to user code.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
|
||||
{
|
||||
/* Is there already a stack allocated of a different size? Because of
|
||||
* alignment issues, stack_size might erroneously appear to be of a
|
||||
* different size. Fortunately, this is not a critical operation.
|
||||
*/
|
||||
|
||||
if (tcb->stack_alloc_ptr && tcb->adj_stack_size != stack_size)
|
||||
{
|
||||
/* Yes.. Release the old stack */
|
||||
|
||||
up_release_stack(tcb, ttype);
|
||||
}
|
||||
|
||||
/* Do we need to allocate a new stack? */
|
||||
|
||||
if (!tcb->stack_alloc_ptr)
|
||||
{
|
||||
/* Allocate the stack. If DEBUG is enabled (but not stack debug),
|
||||
* then create a zeroed stack to make stack dumps easier to trace.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP)
|
||||
/* Use the kernel allocator if this is a kernel thread */
|
||||
|
||||
if (ttype == TCB_FLAG_TTYPE_KERNEL)
|
||||
{
|
||||
tcb->stack_alloc_ptr = (uint32_t *)kmm_malloc(stack_size);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Use the user-space allocator if this is a task or pthread */
|
||||
|
||||
tcb->stack_alloc_ptr = (uint32_t *)kumm_malloc(stack_size);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
/* Was the allocation successful? */
|
||||
|
||||
if (!tcb->stack_alloc_ptr)
|
||||
{
|
||||
sdbg("ERROR: Failed to allocate stack, size %d\n", stack_size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Did we successfully allocate a stack? */
|
||||
|
||||
if (tcb->stack_alloc_ptr)
|
||||
{
|
||||
size_t top_of_stack;
|
||||
size_t size_of_stack;
|
||||
|
||||
/* Yes.. If stack debug is enabled, then fill the stack with a
|
||||
* recognizable value that we can use later to test for high
|
||||
* water marks.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
memset(tcb->stack_alloc_ptr, 0xaa, stack_size);
|
||||
#endif
|
||||
|
||||
/* The i486 uses a push-down stack: the stack grows toward lower
|
||||
* addresses in memory. The stack pointer register, points to the
|
||||
* lowest, valid work address (the "top" of the stack). Items on
|
||||
* the stack are referenced as positive word offsets from sp.
|
||||
*/
|
||||
|
||||
top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4;
|
||||
|
||||
/* The i486 stack must be aligned at word (4 byte) boundaries. If
|
||||
* necessary top_of_stack must be rounded down to the next boundary
|
||||
*/
|
||||
|
||||
top_of_stack &= ~3;
|
||||
size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4;
|
||||
|
||||
/* Save the adjusted stack values in the struct tcb_s */
|
||||
|
||||
tcb->adj_stack_ptr = (uint32_t*)top_of_stack;
|
||||
tcb->adj_stack_size = size_of_stack;
|
||||
|
||||
board_led_on(LED_STACKCREATED);
|
||||
return OK;
|
||||
}
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/i486/up_initialstate.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/arch.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_initial_state
|
||||
*
|
||||
* Description:
|
||||
* A new thread is being started and a new TCB has been created. This
|
||||
* function is called to initialize the processor specific portions of the
|
||||
* new TCB.
|
||||
*
|
||||
* This function must setup the intial architecture registers and/or stack
|
||||
* so that execution will begin at tcb->start on the next context switch.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_initial_state(struct tcb_s *tcb)
|
||||
{
|
||||
struct xcptcontext *xcp = &tcb->xcp;
|
||||
|
||||
/* Initialize the initial exception register context structure */
|
||||
|
||||
memset(xcp, 0, sizeof(struct xcptcontext));
|
||||
|
||||
/* Save the initial stack pointer... the value of the stackpointer before
|
||||
* the "interrupt occurs." We don't know the value of REG_ESP yet..
|
||||
* that depends on if a priority change is required or not.
|
||||
*/
|
||||
|
||||
xcp->regs[REG_SP] = (uint32_t)tcb->adj_stack_ptr;
|
||||
|
||||
/* Save the task entry point */
|
||||
|
||||
xcp->regs[REG_EIP] = (uint32_t)tcb->start;
|
||||
|
||||
/* Set up the segment registers... assume the same segment as the caller.
|
||||
* That is not a good assumption in the long run.
|
||||
*/
|
||||
|
||||
xcp->regs[REG_DS] = up_getds();
|
||||
xcp->regs[REG_CS] = up_getcs();
|
||||
xcp->regs[REG_SS] = up_getss();
|
||||
|
||||
/* Set supervisor- or user-mode, depending on how NuttX is configured and
|
||||
* what kind of thread is being started. Disable FIQs in any event
|
||||
*
|
||||
* If the kernel build is not selected, then all threads run in
|
||||
* supervisor-mode.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
# error "Missing logic for the CONFIG_BUILD_KERNEL build"
|
||||
#endif
|
||||
|
||||
/* Enable or disable interrupts, based on user configuration. If the IF
|
||||
* bit is set, maskable interrupts will be enabled.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_SUPPRESS_INTERRUPTS
|
||||
xcp->regs[REG_EFLAGS] = X86_FLAGS_IF;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,376 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/i486/up_irq.c
|
||||
* arch/x86/src/chip/up_irq.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/irq.h>
|
||||
#include <arch/io.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "qemu_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void idt_outb(uint8_t val, uint16_t addr) noinline_function;
|
||||
static void up_remappic(void);
|
||||
static void up_idtentry(unsigned int index, uint32_t base, uint16_t sel,
|
||||
uint8_t flags);
|
||||
static inline void up_idtinit(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
volatile uint32_t *current_regs;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct idt_entry_s idt_entries[256];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name idt_outb
|
||||
*
|
||||
* Description:
|
||||
* A slightly slower version of outb
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void idt_outb(uint8_t val, uint16_t addr)
|
||||
{
|
||||
outb(val, addr);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name up_remappic
|
||||
*
|
||||
* Description:
|
||||
* Remap the PIC. The Programmable Interrupt Controller (PIC) is used to
|
||||
* combine several sources of interrupt onto one or more CPU lines, while
|
||||
* allowing priority levels to be assigned to its interrupt outputs. When
|
||||
* the device has multiple interrupt outputs to assert, it will assert them
|
||||
* in the order of their relative priority.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void up_remappic(void)
|
||||
{
|
||||
/* Mask interrupts from PIC */
|
||||
|
||||
idt_outb(PIC1_IMR_ALL, PIC1_IMR);
|
||||
idt_outb(PIC2_IMR_ALL, PIC2_IMR);
|
||||
|
||||
/* If the PIC has been reset, it must be initialized with 2 to 4 Initialization
|
||||
* Command Words (ICW) before it will accept and process Interrupt Requests. The
|
||||
* following outlines the four possible Initialization Command Words.
|
||||
*/
|
||||
|
||||
/* Remap the irq table for primary:
|
||||
*
|
||||
* ICW1 - We will be sending ICW4
|
||||
* ICW2 - Address
|
||||
* ICW3 */
|
||||
|
||||
idt_outb(PIC_ICW1_ICW4|PIC_ICW1_ICW1, PIC1_ICW1);
|
||||
idt_outb(0x20, PIC1_ICW2);
|
||||
idt_outb(PIC1_ICW3_IRQ2, PIC1_ICW3);
|
||||
idt_outb(PIC_ICW4_808xMODE, PIC1_ICW4);
|
||||
|
||||
/* Remap irq for slave */
|
||||
|
||||
idt_outb(PIC_ICW1_ICW4|PIC_ICW1_ICW1, PIC2_ICW1);
|
||||
idt_outb(0x28, PIC2_ICW2);
|
||||
idt_outb(PIC_ICW3_SID2, PIC2_ICW3);
|
||||
idt_outb(PIC_ICW4_808xMODE, PIC2_ICW4);
|
||||
|
||||
/* Mask interrupts from PIC */
|
||||
|
||||
idt_outb(PIC1_IMR_ALL, PIC1_IMR);
|
||||
idt_outb(PIC2_IMR_ALL, PIC2_IMR);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name up_idtentry
|
||||
*
|
||||
* Description:
|
||||
* Initialize one IDT entry.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void up_idtentry(unsigned int index, uint32_t base, uint16_t sel,
|
||||
uint8_t flags)
|
||||
{
|
||||
struct idt_entry_s *entry = &idt_entries[index];
|
||||
|
||||
entry->lobase = base & 0xffff;
|
||||
entry->hibase = (base >> 16) & 0xffff;
|
||||
|
||||
entry->sel = sel;
|
||||
entry->zero = 0;
|
||||
|
||||
/* We must uncomment the OR below when we get to using user-mode. It sets the
|
||||
* interrupt gate's privilege level to 3.
|
||||
*/
|
||||
|
||||
entry->flags = flags /* | 0x60 */;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name up_idtinit
|
||||
*
|
||||
* Description:
|
||||
* Initialize the IDT. The Interrupt Descriptor Table (IDT) is a data
|
||||
* structure used by the x86 architecture to implement an interrupt vector
|
||||
* table. The IDT is used by the processor to determine the correct
|
||||
* response to interrupts and exceptions.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void up_idtinit(void)
|
||||
{
|
||||
struct idt_ptr_s idt_ptr;
|
||||
|
||||
idt_ptr.limit = sizeof(struct idt_entry_s) * 256 - 1;
|
||||
idt_ptr.base = (uint32_t)&idt_entries;
|
||||
|
||||
memset(&idt_entries, 0, sizeof(struct idt_entry_s)*256);
|
||||
|
||||
/* Re-map the PIC */
|
||||
|
||||
up_remappic();
|
||||
|
||||
/* Set each ISR/IRQ to the appropriate vector with selector=8 and with
|
||||
* 32-bit interrupt gate. Interrupt gate (vs. trap gate) will leave
|
||||
* interrupts enabled when the IRS/IRQ handler is entered.
|
||||
*/
|
||||
|
||||
up_idtentry(ISR0, (uint32_t)vector_isr0 , 0x08, 0x8e);
|
||||
up_idtentry(ISR1, (uint32_t)vector_isr1 , 0x08, 0x8e);
|
||||
up_idtentry(ISR2, (uint32_t)vector_isr2 , 0x08, 0x8e);
|
||||
up_idtentry(ISR3, (uint32_t)vector_isr3 , 0x08, 0x8e);
|
||||
up_idtentry(ISR4, (uint32_t)vector_isr4 , 0x08, 0x8e);
|
||||
up_idtentry(ISR5, (uint32_t)vector_isr5 , 0x08, 0x8e);
|
||||
up_idtentry(ISR6, (uint32_t)vector_isr6 , 0x08, 0x8e);
|
||||
up_idtentry(ISR7, (uint32_t)vector_isr7 , 0x08, 0x8e);
|
||||
up_idtentry(ISR8, (uint32_t)vector_isr8 , 0x08, 0x8e);
|
||||
up_idtentry(ISR9, (uint32_t)vector_isr9 , 0x08, 0x8e);
|
||||
up_idtentry(ISR10, (uint32_t)vector_isr10, 0x08, 0x8e);
|
||||
up_idtentry(ISR11, (uint32_t)vector_isr11, 0x08, 0x8e);
|
||||
up_idtentry(ISR12, (uint32_t)vector_isr12, 0x08, 0x8e);
|
||||
up_idtentry(ISR13, (uint32_t)vector_isr13, 0x08, 0x8e);
|
||||
up_idtentry(ISR14, (uint32_t)vector_isr14, 0x08, 0x8e);
|
||||
up_idtentry(ISR15, (uint32_t)vector_isr15, 0x08, 0x8e);
|
||||
up_idtentry(ISR16, (uint32_t)vector_isr16, 0x08, 0x8e);
|
||||
up_idtentry(ISR17, (uint32_t)vector_isr17, 0x08, 0x8e);
|
||||
up_idtentry(ISR18, (uint32_t)vector_isr18, 0x08, 0x8e);
|
||||
up_idtentry(ISR19, (uint32_t)vector_isr19, 0x08, 0x8e);
|
||||
up_idtentry(ISR20, (uint32_t)vector_isr20, 0x08, 0x8e);
|
||||
up_idtentry(ISR21, (uint32_t)vector_isr21, 0x08, 0x8e);
|
||||
up_idtentry(ISR22, (uint32_t)vector_isr22, 0x08, 0x8e);
|
||||
up_idtentry(ISR23, (uint32_t)vector_isr23, 0x08, 0x8e);
|
||||
up_idtentry(ISR24, (uint32_t)vector_isr24, 0x08, 0x8e);
|
||||
up_idtentry(ISR25, (uint32_t)vector_isr25, 0x08, 0x8e);
|
||||
up_idtentry(ISR26, (uint32_t)vector_isr26, 0x08, 0x8e);
|
||||
up_idtentry(ISR27, (uint32_t)vector_isr27, 0x08, 0x8e);
|
||||
up_idtentry(ISR28, (uint32_t)vector_isr28, 0x08, 0x8e);
|
||||
up_idtentry(ISR29, (uint32_t)vector_isr29, 0x08, 0x8e);
|
||||
up_idtentry(ISR30, (uint32_t)vector_isr30, 0x08, 0x8e);
|
||||
up_idtentry(ISR31, (uint32_t)vector_isr31, 0x08, 0x8e);
|
||||
|
||||
up_idtentry(IRQ0, (uint32_t)vector_irq0, 0x08, 0x8e);
|
||||
up_idtentry(IRQ1, (uint32_t)vector_irq1, 0x08, 0x8e);
|
||||
up_idtentry(IRQ2, (uint32_t)vector_irq2, 0x08, 0x8e);
|
||||
up_idtentry(IRQ3, (uint32_t)vector_irq3, 0x08, 0x8e);
|
||||
up_idtentry(IRQ4, (uint32_t)vector_irq4, 0x08, 0x8e);
|
||||
up_idtentry(IRQ5, (uint32_t)vector_irq5, 0x08, 0x8e);
|
||||
up_idtentry(IRQ6, (uint32_t)vector_irq6, 0x08, 0x8e);
|
||||
up_idtentry(IRQ7, (uint32_t)vector_irq7, 0x08, 0x8e);
|
||||
up_idtentry(IRQ8, (uint32_t)vector_irq8, 0x08, 0x8e);
|
||||
up_idtentry(IRQ9, (uint32_t)vector_irq9, 0x08, 0x8e);
|
||||
up_idtentry(IRQ10, (uint32_t)vector_irq10, 0x08, 0x8e);
|
||||
up_idtentry(IRQ11, (uint32_t)vector_irq11, 0x08, 0x8e);
|
||||
up_idtentry(IRQ12, (uint32_t)vector_irq12, 0x08, 0x8e);
|
||||
up_idtentry(IRQ13, (uint32_t)vector_irq13, 0x08, 0x8e);
|
||||
up_idtentry(IRQ14, (uint32_t)vector_irq14, 0x08, 0x8e);
|
||||
up_idtentry(IRQ15, (uint32_t)vector_irq15, 0x08, 0x8e);
|
||||
|
||||
/* Then program the IDT */
|
||||
|
||||
idt_flush((uint32_t)&idt_ptr);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irqinitialize
|
||||
****************************************************************************/
|
||||
|
||||
void up_irqinitialize(void)
|
||||
{
|
||||
/* currents_regs is non-NULL only while processing an interrupt */
|
||||
|
||||
current_regs = NULL;
|
||||
|
||||
/* Initialize the IDT */
|
||||
|
||||
up_idtinit();
|
||||
|
||||
/* And finally, enable interrupts */
|
||||
|
||||
#ifndef CONFIG_SUPPRESS_INTERRUPTS
|
||||
irqrestore(X86_FLAGS_IF);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_disable_irq
|
||||
*
|
||||
* Description:
|
||||
* Disable the IRQ specified by 'irq'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_disable_irq(int irq)
|
||||
{
|
||||
unsigned int regaddr;
|
||||
uint8_t regbit;
|
||||
|
||||
if (irq >= IRQ0)
|
||||
{
|
||||
/* Map the IRQ IMR regiser to a PIC and a bit number */
|
||||
|
||||
if (irq <= IRQ7)
|
||||
{
|
||||
regaddr = PIC1_IMR;
|
||||
regbit = (1 << (irq - IRQ0));
|
||||
}
|
||||
else if (irq <= IRQ15)
|
||||
{
|
||||
regaddr = PIC2_IMR;
|
||||
regbit = (1 << (irq - IRQ8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Disable (mask) the interrupt */
|
||||
|
||||
modifyreg8(regaddr, 0, regbit);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_enable_irq
|
||||
*
|
||||
* Description:
|
||||
* Enable the IRQ specified by 'irq'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_enable_irq(int irq)
|
||||
{
|
||||
unsigned int regaddr;
|
||||
uint8_t regbit;
|
||||
|
||||
if (irq >= IRQ0)
|
||||
{
|
||||
/* Map the IRQ IMR regiser to a PIC and a bit number */
|
||||
|
||||
if (irq <= IRQ7)
|
||||
{
|
||||
regaddr = PIC1_IMR;
|
||||
regbit = (1 << (irq - IRQ0));
|
||||
}
|
||||
else if (irq <= IRQ15)
|
||||
{
|
||||
regaddr = PIC2_IMR;
|
||||
regbit = (1 << (irq - IRQ8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Enable (unmask) the interrupt */
|
||||
|
||||
modifyreg8(regaddr, regbit, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_prioritize_irq
|
||||
*
|
||||
* Description:
|
||||
* Set the priority of an IRQ.
|
||||
*
|
||||
* Since this API is not supported on all architectures, it should be
|
||||
* avoided in common implementations where possible.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQPRIO
|
||||
int up_prioritize_irq(int irq, int priority)
|
||||
{
|
||||
#warning "Missing Logic"
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
@@ -1,84 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/i486/up_regdump.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/* Output debug info -- even if debug is not selected. */
|
||||
|
||||
#undef CONFIG_DEBUG
|
||||
#undef CONFIG_DEBUG_VERBOSE
|
||||
#define CONFIG_DEBUG 1
|
||||
#define CONFIG_DEBUG_VERBOSE 1
|
||||
|
||||
#include <debug.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
/****************************************************************************
|
||||
* Name: up_registerdump
|
||||
****************************************************************************/
|
||||
|
||||
void up_registerdump(uint32_t *regs)
|
||||
{
|
||||
lldbg(" ds:%08x irq:%08x err:%08x\n",
|
||||
regs[REG_DS], regs[REG_IRQNO], regs[REG_ERRCODE]);
|
||||
lldbg("edi:%08x esi:%08x ebp:%08x esp:%08x\n",
|
||||
regs[REG_EDI], regs[REG_ESI], regs[REG_EBP], regs[REG_ESP]);
|
||||
lldbg("ebx:%08x edx:%08x ecx:%08x eax:%08x\n",
|
||||
regs[REG_EBX], regs[REG_EDX], regs[REG_ECX], regs[REG_EAX]);
|
||||
lldbg("eip:%08x cs:%08x flg:%08x sp:%08x ss:%08x\n",
|
||||
regs[REG_EIP], regs[REG_CS], regs[REG_EFLAGS], regs[REG_SP],
|
||||
regs[REG_SS]);
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/common/up_releasestack.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_release_stack
|
||||
*
|
||||
* Description:
|
||||
* A task has been stopped. Free all stack related resources retained in
|
||||
* the defunct TCB.
|
||||
*
|
||||
* Input Parmeters
|
||||
* - dtcb: The TCB containing information about the stack to be released
|
||||
* - ttype: The thread type. This may be one of following (defined in
|
||||
* include/nuttx/sched.h):
|
||||
*
|
||||
* TCB_FLAG_TTYPE_TASK Normal user task
|
||||
* TCB_FLAG_TTYPE_PTHREAD User pthread
|
||||
* TCB_FLAG_TTYPE_KERNEL Kernel thread
|
||||
*
|
||||
* This thread type is normally available in the flags field of the TCB,
|
||||
* however, there are certain error recovery contexts where the TCB may
|
||||
* not be fully initialized when up_release_stack is called.
|
||||
*
|
||||
* If CONFIG_BUILD_KERNEL is defined, then this thread type may affect
|
||||
* how the stack is freed. For example, kernel thread stacks may have
|
||||
* been allocated from protected kernel memory. Stacks for user tasks
|
||||
* and threads must have come from memory that is accessible to user
|
||||
* code.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype)
|
||||
{
|
||||
/* Is there a stack allocated? */
|
||||
|
||||
if (dtcb->stack_alloc_ptr)
|
||||
{
|
||||
#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP)
|
||||
/* Use the kernel allocator if this is a kernel thread */
|
||||
|
||||
if (ttype == TCB_FLAG_TTYPE_KERNEL)
|
||||
{
|
||||
sched_kfree(dtcb->stack_alloc_ptr);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Use the user-space allocator if this is a task or pthread */
|
||||
|
||||
sched_ufree(dtcb->stack_alloc_ptr);
|
||||
}
|
||||
|
||||
/* Mark the stack freed */
|
||||
|
||||
dtcb->stack_alloc_ptr = NULL;
|
||||
}
|
||||
|
||||
/* The size of the allocated stack is now zero */
|
||||
|
||||
dtcb->adj_stack_size = 0;
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/i486/up_savestate.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/arch.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
/****************************************************************************
|
||||
* Name: up_savestate
|
||||
*
|
||||
* Description:
|
||||
* This function saves the interrupt level context information in the
|
||||
* TCB. This would just be a up_copystate but we have to handle one
|
||||
* special case. In the case where the privilige level changes, the
|
||||
* value of sp and ss will not be saved on stack by the interrupt handler.
|
||||
* So, in that case, we will have to fudge those values here.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_savestate(uint32_t *regs)
|
||||
{
|
||||
uint8_t cpl;
|
||||
uint8_t rpl;
|
||||
|
||||
/* First, just copy all of the registers */
|
||||
|
||||
up_copystate(regs, (uint32_t*)current_regs);
|
||||
|
||||
/* The RES_SP and REG_SS values will not be saved by the interrupt handling
|
||||
* logic if there is no change in privilege level. In that case, we will
|
||||
* have to "fudge" those values here. For now, just overwrite the REG_SP
|
||||
* and REG_SS values with what we believe to be correct. Obviously, this
|
||||
* will have to change in the future to support multi-segment operation.
|
||||
*
|
||||
* Check for a change in privilege level.
|
||||
*/
|
||||
|
||||
rpl = regs[REG_CS] & 3;
|
||||
cpl = up_getcs() & 3;
|
||||
DEBUGASSERT(rpl >= cpl);
|
||||
|
||||
if (rpl == cpl)
|
||||
{
|
||||
/* No priority change, SP and SS are not present in the stack frame.
|
||||
*
|
||||
* The value saved in the REG_ESP will be the stackpointer value prior to
|
||||
* the execution of the PUSHA. It will point at REG_IRQNO.
|
||||
*/
|
||||
|
||||
regs[REG_SP] = current_regs[REG_ESP] + 4*BOTTOM_NOPRIO;
|
||||
regs[REG_SS] = up_getss();
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUGASSERT(regs[REG_SP] == current_regs[REG_ESP] + 4*BOTTOM_PRIO);
|
||||
}
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/x86/src/i486/up_schedulesigaction.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "up_internal.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_schedule_sigaction
|
||||
*
|
||||
* Description:
|
||||
* This function is called by the OS when one or more signal handling
|
||||
* actions have been queued for execution. The architecture specific code
|
||||
* must configure things so that the 'sigdeliver' callback is executed on
|
||||
* the thread specified by 'tcb' as soon as possible.
|
||||
*
|
||||
* This function may be called from interrupt handling logic.
|
||||
*
|
||||
* This operation should not cause the task to be unblocked nor should it
|
||||
* cause any immediate execution of sigdeliver. Typically, a few cases need
|
||||
* to be considered:
|
||||
*
|
||||
* (1) This function may be called from an interrupt handler. During
|
||||
* interrupt processing, all xcptcontext structures should be valid for
|
||||
* all tasks. That structure should be modified to invoke sigdeliver()
|
||||
* either on return from (this) interrupt or on some subsequent context
|
||||
* switch to the recipient task.
|
||||
* (2) If not in an interrupt handler and the tcb is NOT the currently
|
||||
* executing task, then again just modify the saved xcptcontext
|
||||
* structure for the recipient task so it will invoke sigdeliver when
|
||||
* that task is later resumed.
|
||||
* (3) If not in an interrupt handler and the tcb IS the currently
|
||||
* executing task -- just call the signal handler now.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
|
||||
{
|
||||
/* Refuse to handle nested signal actions */
|
||||
|
||||
sdbg("tcb=0x%p sigdeliver=0x%p\n", tcb, sigdeliver);
|
||||
|
||||
if (!tcb->xcp.sigdeliver)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
/* Make sure that interrupts are disabled */
|
||||
|
||||
flags = irqsave();
|
||||
|
||||
/* First, handle some special cases when the signal is being delivered
|
||||
* to the currently executing task.
|
||||
*/
|
||||
|
||||
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
|
||||
|
||||
if (tcb == (struct tcb_s*)g_readytorun.head)
|
||||
{
|
||||
/* CASE 1: We are not in an interrupt handler and a task is
|
||||
* signalling itself for some reason.
|
||||
*/
|
||||
|
||||
if (!current_regs)
|
||||
{
|
||||
/* In this case just deliver the signal now. */
|
||||
|
||||
sigdeliver(tcb);
|
||||
}
|
||||
|
||||
/* CASE 2: We are in an interrupt handler AND the interrupted task
|
||||
* is the same as the one that must receive the signal, then we will
|
||||
* have to modify the return state as well as the state in the TCB.
|
||||
*
|
||||
* Hmmm... there looks like a latent bug here: The following logic
|
||||
* would fail in the strange case where we are in an interrupt
|
||||
* handler, the thread is signalling itself, but a context switch to
|
||||
* another task has occurred so that current_regs does not refer to
|
||||
* the thread at g_readytorun.head!
|
||||
*/
|
||||
|
||||
else
|
||||
{
|
||||
/* Save the return lr and cpsr and one scratch register. These
|
||||
* will be restored by the signal trampoline after the signals
|
||||
* have been delivered.
|
||||
*/
|
||||
|
||||
tcb->xcp.sigdeliver = sigdeliver;
|
||||
tcb->xcp.saved_eip = current_regs[REG_EIP];
|
||||
tcb->xcp.saved_eflags = current_regs[REG_EFLAGS];
|
||||
|
||||
/* Then set up to vector to the trampoline with interrupts
|
||||
* disabled
|
||||
*/
|
||||
|
||||
current_regs[REG_EIP] = (uint32_t)up_sigdeliver;
|
||||
current_regs[REG_EFLAGS] = 0;
|
||||
|
||||
/* And make sure that the saved context in the TCB
|
||||
* is the same as the interrupt return context.
|
||||
*/
|
||||
|
||||
up_savestate(tcb->xcp.regs);
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise, we are (1) signaling a task is not running
|
||||
* from an interrupt handler or (2) we are not in an
|
||||
* interrupt handler and the running task is signalling
|
||||
* some non-running task.
|
||||
*/
|
||||
|
||||
else
|
||||
{
|
||||
/* Save the return lr and cpsr and one scratch register
|
||||
* These will be restored by the signal trampoline after
|
||||
* the signals have been delivered.
|
||||
*/
|
||||
|
||||
tcb->xcp.sigdeliver = sigdeliver;
|
||||
tcb->xcp.saved_eip = tcb->xcp.regs[REG_EIP];
|
||||
tcb->xcp.saved_eflags = tcb->xcp.regs[REG_EFLAGS];
|
||||
|
||||
/* Then set up to vector to the trampoline with interrupts
|
||||
* disabled
|
||||
*/
|
||||
|
||||
tcb->xcp.regs[REG_EIP] = (uint32_t)up_sigdeliver;
|
||||
tcb->xcp.regs[REG_EFLAGS] = 0;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_DISABLE_SIGNALS */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user