Adding context switching logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@561 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
bf27d79c0d
commit
ee1d841569
7
TODO
7
TODO
@ -21,6 +21,7 @@ NuttX TODO List (Last updated January 6, 2008)
|
||||
(2) ARM/LPC214x (arch/arm/src/lpc214x/)
|
||||
(4) pjrc-8052 / MCS51 (arch/pjrc-8051/)
|
||||
(2) z80 (arch/z80/)
|
||||
(1) z16 (arch/z16/)
|
||||
|
||||
o Task/Scheduler (sched/)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -350,4 +351,10 @@ o z80 (arch/z80)
|
||||
to solve the problem are complex.
|
||||
|
||||
|
||||
o z16 (arch/z16)
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Description: ZDS-II Librarian complains that the source for the .obj file
|
||||
is not in the library.
|
||||
Status: Open
|
||||
Priority: Low, thought to be cosmetic.
|
||||
|
@ -43,6 +43,6 @@ CMN_CSRCS = up_allocateheap.c up_initialize.c up_schedulesigaction.c \
|
||||
up_unblocktask.c up_doirq.c up_releasepending.c up_usestack.c \
|
||||
up_exit.c up_releasestack.c up_idle.c up_reprioritizertr.c
|
||||
|
||||
CHIP_SSRCS = z16f_lowuart.S
|
||||
CHIP_SSRCS = z16f_lowuart.S z16f_saveusercontext.S
|
||||
CHIP_CSRCS = z16f_clkinit.c z16f_irq.c z16f_timerisr.c z16f_serial.c
|
||||
|
||||
|
@ -367,41 +367,41 @@
|
||||
|
||||
/* UART0/1 Status 0 Register Bit Definitions ****************************************/
|
||||
|
||||
#define Z16F_UARTSTAT0_RDA _HX8(0x80) /* Bit 7: Receive Data Available */
|
||||
#define Z16F_UARTSTAT0_PE _HX8(0x40) /* Bit 6: Parity Error */
|
||||
#define Z16F_UARTSTAT0_OE _HX8(0x20) /* Bit 5: Overrun Error */
|
||||
#define Z16F_UARTSTAT0_FE _HX8(0x10) /* Bit 4: Framing Error */
|
||||
#define Z16F_UARTSTAT0_BRKD _HX8(0x08) /* Bit 3: Break Detect */
|
||||
#define Z16F_UARTSTAT0_TDRE _HX8(0x04) /* Bit 2: Transmitter Data Register Empty */
|
||||
#define Z16F_UARTSTAT0_TXE _HX8(0x02) /* Bit 1: Transmitter Empty */
|
||||
#define Z16F_UARTSTAT0_CTS _HX8(0x01) /* Bit 0: Clear To Send */
|
||||
#define Z16F_UARTSTAT0_RDA _HX8(80) /* Bit 7: Receive Data Available */
|
||||
#define Z16F_UARTSTAT0_PE _HX8(40) /* Bit 6: Parity Error */
|
||||
#define Z16F_UARTSTAT0_OE _HX8(20) /* Bit 5: Overrun Error */
|
||||
#define Z16F_UARTSTAT0_FE _HX8(10) /* Bit 4: Framing Error */
|
||||
#define Z16F_UARTSTAT0_BRKD _HX8(08) /* Bit 3: Break Detect */
|
||||
#define Z16F_UARTSTAT0_TDRE _HX8(04) /* Bit 2: Transmitter Data Register Empty */
|
||||
#define Z16F_UARTSTAT0_TXE _HX8(02) /* Bit 1: Transmitter Empty */
|
||||
#define Z16F_UARTSTAT0_CTS _HX8(01) /* Bit 0: Clear To Send */
|
||||
|
||||
/* UART0/1 Control 0/1 Register Bit Definitions *************************************/
|
||||
|
||||
#define Z16F_UARTCTL0_TEN _HX8(0x80) /* Bit 7: Transmit Enable */
|
||||
#define Z16F_UARTCTL0_REN _HX8(0x40) /* Bit 6: Receive Enable */
|
||||
#define Z16F_UARTCTL0_CTSE _HX8(0x20) /* Bit 5: CTS Enable */
|
||||
#define Z16F_UARTCTL0_PEN _HX8(0x10) /* Bit 4: Parity Enable */
|
||||
#define Z16F_UARTCTL0_PSEL _HX8(0x08) /* Bit 3: Odd Parity Select */
|
||||
#define Z16F_UARTCTL0_SBRK _HX8(0x04) /* Bit 2: Send Break */
|
||||
#define Z16F_UARTCTL0_STOP _HX8(0x02) /* Bit 1: Stop Bit Select */
|
||||
#define Z16F_UARTCTL0_LBEN _HX8(0x01) /* Bit 0: Loopback Enable */
|
||||
#define Z16F_UARTCTL0_TEN _HX8(80) /* Bit 7: Transmit Enable */
|
||||
#define Z16F_UARTCTL0_REN _HX8(40) /* Bit 6: Receive Enable */
|
||||
#define Z16F_UARTCTL0_CTSE _HX8(20) /* Bit 5: CTS Enable */
|
||||
#define Z16F_UARTCTL0_PEN _HX8(10) /* Bit 4: Parity Enable */
|
||||
#define Z16F_UARTCTL0_PSEL _HX8(08) /* Bit 3: Odd Parity Select */
|
||||
#define Z16F_UARTCTL0_SBRK _HX8(04) /* Bit 2: Send Break */
|
||||
#define Z16F_UARTCTL0_STOP _HX8(02) /* Bit 1: Stop Bit Select */
|
||||
#define Z16F_UARTCTL0_LBEN _HX8(01) /* Bit 0: Loopback Enable */
|
||||
|
||||
#define Z16F_UARTCTL1_MPMD1 _HX8(0x80) /* Bit 7: Multiprocessor Mode (bit1) */
|
||||
#define Z16F_UARTCTL1_MPEN _HX8(0x40) /* Bit 6: Multiprocessor Enable */
|
||||
#define Z16F_UARTCTL1_MPMD0 _HX8(0x20) /* Bit 5: Multiprocessor Mode (bit0) */
|
||||
#define Z16F_UARTCTL1_MPBT _HX8(0x10) /* Bit 4: Multiprocessor Bit Transmit */
|
||||
#define Z16F_UARTCTL1_DEPOL _HX8(0x08) /* Bit 3: Driver Enable Polarity */
|
||||
#define Z16F_UARTCTL1_BRGCTL _HX8(0x04) /* Bit 2: Baud Rate Generator Control */
|
||||
#define Z16F_UARTCTL1_RDAIRQ _HX8(0x02) /* Bit 1: Receive Data Interrupt Enable */
|
||||
#define Z16F_UARTCTL1_IREN _HX8(0x01) /* Bit 0: Infrared Encoder/Decoder Eanble */
|
||||
#define Z16F_UARTCTL1_MPMD1 _HX8(80) /* Bit 7: Multiprocessor Mode (bit1) */
|
||||
#define Z16F_UARTCTL1_MPEN _HX8(40) /* Bit 6: Multiprocessor Enable */
|
||||
#define Z16F_UARTCTL1_MPMD0 _HX8(20) /* Bit 5: Multiprocessor Mode (bit0) */
|
||||
#define Z16F_UARTCTL1_MPBT _HX8(10) /* Bit 4: Multiprocessor Bit Transmit */
|
||||
#define Z16F_UARTCTL1_DEPOL _HX8(08) /* Bit 3: Driver Enable Polarity */
|
||||
#define Z16F_UARTCTL1_BRGCTL _HX8(04) /* Bit 2: Baud Rate Generator Control */
|
||||
#define Z16F_UARTCTL1_RDAIRQ _HX8(02) /* Bit 1: Receive Data Interrupt Enable */
|
||||
#define Z16F_UARTCTL1_IREN _HX8(01) /* Bit 0: Infrared Encoder/Decoder Eanble */
|
||||
|
||||
/* UART0/1 Mode Status/Select Register Bit Definitions ******************************/
|
||||
|
||||
#define Z16F_UARTMDSEL_NORMAL _HX8(0x00) /* Bits 5-7=0: Multiprocessor and Normal Mode */
|
||||
#define Z16F_UARTMDSEL_FILTER _HX8(0x20) /* Bits 5-7=1: Noise Filter Control/Status */
|
||||
#define Z16F_UARTMDSEL_LINP _HX8(0x40) /* Bits 5-7=2: LIN protocol Contol/Status */
|
||||
#define Z16F_UARTMDSEL_HWREV _HX8(0xe0) /* Bits 5-7=7: LIN-UART Hardware Revision */
|
||||
#define Z16F_UARTMDSEL_NORMAL _HX8(00) /* Bits 5-7=0: Multiprocessor and Normal Mode */
|
||||
#define Z16F_UARTMDSEL_FILTER _HX8(20) /* Bits 5-7=1: Noise Filter Control/Status */
|
||||
#define Z16F_UARTMDSEL_LINP _HX8(40) /* Bits 5-7=2: LIN protocol Contol/Status */
|
||||
#define Z16F_UARTMDSEL_HWREV _HX8(e0) /* Bits 5-7=7: LIN-UART Hardware Revision */
|
||||
/* Bits 0-4: Mode dependent status */
|
||||
|
||||
/* Timer0/1/2 registers *************************************************************/
|
||||
|
@ -77,6 +77,20 @@
|
||||
xdef _c0_isr
|
||||
xdef _common_isr
|
||||
|
||||
xref _low_nearbss:RAM
|
||||
xref _len_nearbss
|
||||
xref _low_farbss:ERAM
|
||||
xref _len_farbss:ERAM
|
||||
xref _low_neardata:RAM
|
||||
xref _len_neardata
|
||||
xref _low_near_romdata:EROM
|
||||
xref _low_fardata:ERAM
|
||||
xref _len_fardata:ERAM
|
||||
xref _low_far_romdata:EROM
|
||||
xref far_heapbot:ERAM
|
||||
xref _far_stack:ERAM
|
||||
xref _near_stack:RAM
|
||||
|
||||
/**************************************************************************
|
||||
* Flash Option Byte Setup
|
||||
**************************************************************************/
|
||||
@ -123,8 +137,6 @@
|
||||
* Equates
|
||||
**************************************************************************/
|
||||
|
||||
STACK_TOP equ %FFC000
|
||||
|
||||
/**************************************************************************
|
||||
* Data Allocation
|
||||
**************************************************************************/
|
||||
@ -145,11 +157,68 @@ STACK_TOP equ %FFC000
|
||||
**************************************************************************/
|
||||
|
||||
_reset:
|
||||
ld sp, #STACK_TOP /* Set Stack Pointer */
|
||||
call _z16f_lowinit /* Perform low-level hardware initialization */
|
||||
/* Initialize the init/idle task stack */
|
||||
|
||||
ld sp, #(_near_stack+1) /* Set Stack Pointer to the top of internal RAM */
|
||||
clr fp
|
||||
|
||||
/* Perform VERY early UART initialization so that we can use it here */
|
||||
|
||||
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_ARCH_LOWGETC)
|
||||
call _z16f_lowuartinit /* Initialize the UART for debugging */
|
||||
#endif
|
||||
/* Initialize the hardware stack overflow register */
|
||||
|
||||
#ifdef CONFIG_Z16F_INITSPOV
|
||||
ld r0, #(_near_stack_bot+1)
|
||||
ld spov, r0
|
||||
#endif
|
||||
/* Clear BSS */
|
||||
|
||||
lea r0, _low_nearbss
|
||||
ld r1, #_len_nearbss+1
|
||||
jp _reset2
|
||||
_reset1:
|
||||
ld.b (r0++), #0
|
||||
_reset2:
|
||||
djnz r1, _reset1
|
||||
|
||||
lea r0, _low_farbss
|
||||
ld r1, #_len_farbss+1
|
||||
jp _reset4
|
||||
_reset3:
|
||||
ld.b (r0++), #0
|
||||
_reset4:
|
||||
djnz r1, _reset3
|
||||
|
||||
/* Copy ROM data into RAM */
|
||||
|
||||
lea r0, _low_near_romdata
|
||||
lea r1, _low_neardata
|
||||
ld r2, #_len_neardata+1
|
||||
jp _reset6
|
||||
_reset5:
|
||||
ld.b r3, (r0++)
|
||||
ld.b (r1++), r3
|
||||
_reset6:
|
||||
djnz r2, _reset5
|
||||
|
||||
lea r0, _low_far_romdata
|
||||
lea r1, _low_fardata
|
||||
ld r2, #_len_fardata+1
|
||||
jp _reset8
|
||||
_reset7:
|
||||
ld.b r3, (r0++)
|
||||
ld.b (r1++), r3
|
||||
_reset8:
|
||||
djnz r2, _reset7
|
||||
|
||||
/* Perform low-level hardware initialization */
|
||||
|
||||
call _z16f_lowinit /* Perform low-level hardware initialization */
|
||||
|
||||
/* Start NuttX */
|
||||
|
||||
call _os_start /* Start the operating system */
|
||||
_halted: /* _os_start() should not return */
|
||||
halt
|
||||
|
@ -57,10 +57,6 @@
|
||||
xdef _up_lowgetc
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
* Data Allocation
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Data Allocation
|
||||
*************************************************************************/
|
||||
@ -147,7 +143,7 @@ _z16f_xmitc:
|
||||
pushmlo <r0> /* Save registers */
|
||||
|
||||
_z16f_xmitc1:
|
||||
ld r0, #Z16F_UARTSTAT0_TDRE /* TDRE=Transmitter Data Register Empty */
|
||||
ld r0, Z16F_UARTSTAT0_TDRE /* TDRE=Transmitter Data Register Empty */
|
||||
#ifdef CONFIG_UART0_SERIAL_CONSOLE
|
||||
tm.b Z16F_UART0_STAT0, r0 /* r0 = Z16F_UART0_STAT0 */
|
||||
jp eq, _z16f_xmitc1 /* While (!(Z16F_UART0_STAT0 & TDRE)) */
|
||||
@ -178,9 +174,9 @@ _z16f_xmitc1:
|
||||
#ifdef CONFIG_ARCH_LOWPUTC
|
||||
_up_lowputc:
|
||||
pushmlo <r1,r5> /* Save registers */
|
||||
ld r0,r1
|
||||
ext.ub r5,r0
|
||||
cp r5,#10
|
||||
ld r0, r1
|
||||
ext.ub r5, r0
|
||||
cp r5, #10
|
||||
jp ne, _up_lowputc1 /* If (character == \n) */
|
||||
|
||||
ld r1,#13
|
||||
|
104
arch/z16/src/z16f/z16f_saveusercontext.S
Normal file
104
arch/z16/src/z16f/z16f_saveusercontext.S
Normal file
@ -0,0 +1,104 @@
|
||||
/*************************************************************************
|
||||
* arch/z16/src/z16f/z16f_saveusercontext.asm
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSeqUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Included Files
|
||||
*************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <arch/irq.h>
|
||||
#include "chip/chip.h"
|
||||
|
||||
/*************************************************************************
|
||||
* External References / External Definitions
|
||||
*************************************************************************/
|
||||
|
||||
xdef up_saveusercontext
|
||||
|
||||
/*************************************************************************
|
||||
* Data Allocation
|
||||
*************************************************************************/
|
||||
|
||||
define CODESEG, SPACE=EROM
|
||||
segment CODESEG
|
||||
|
||||
/*************************************************************************
|
||||
* Code
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: up_saveusercontext
|
||||
*
|
||||
* Description:
|
||||
* Save the current user context.
|
||||
* r0-r7: These are caller saved registers and do not need to be stored
|
||||
* here
|
||||
* r8-r13: There callee saved registers must be preserved
|
||||
* r14: Frame pointer
|
||||
* r15: Stack pointer (with return address on stack)
|
||||
*
|
||||
* Parameters:
|
||||
* r1: pointer to the register save array in the XCPT structure
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
up_saveusercontext:
|
||||
/* Save the flags (needed to restore the interrupt state) */
|
||||
|
||||
ld r3, Z16F_CNTRL_FLAGS /* Fetch the flags register */
|
||||
sll r3, #8 /* Pad with zero */
|
||||
ld 2*REG_FLAGS(r1), r3
|
||||
|
||||
/* Save r8-R13 */
|
||||
|
||||
ld 2*REG_R8(r1), r8 /* Save r8 */
|
||||
ld 2*REG_R8(r1), r9 /* Save r9 */
|
||||
ld 2*REG_R8(r1), r10 /* Save r10 */
|
||||
ld 2*REG_R8(r1), r11 /* Save r11 */
|
||||
ld 2*REG_R8(r1), r12 /* Save r12 */
|
||||
ld 2*REG_R8(r1), r13 /* Save r13 */
|
||||
|
||||
/* Save the stack pointer and the frame pointer */
|
||||
|
||||
ld 2*REG_FP(r1), fp /* Save the frame pointer */
|
||||
ld 2*REG_SP(r1), sp /* Save the stack pointer */
|
||||
|
||||
/* Save the return address at the top of the stack */
|
||||
|
||||
ld r0, (sp) /* Save the return address */
|
||||
ld 2*REG_PC(r1), r0
|
||||
clr r0 /* Always returns 0 */
|
||||
ret
|
||||
end
|
@ -51,7 +51,7 @@
|
||||
#include <nuttx/serial.h>
|
||||
#include <arch/serial.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "chip/chip.h"
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user