OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ucos-ii/] [2.91/] [include/] [os_cpu.h] - Blame information for rev 471

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 471 julius
/*
2
----------------------------------------------------------------------
3
    CHiPES Embedded RTR Systems Copyright (c) Tim Oliver 2002-2004
4
----------------------------------------------------------------------
5
 File   : os_cpu.h
6
 Author : Tim Oliver
7
 Email  : timtimoliver@yahoo.co.uk
8
---------------------------[Description]------------------------------
9
 
10
                Part of the OpenRISC Reference Platform Port of MicroC/OS-II
11
 
12
-------------------------[CVS Information]----------------------------
13
  $Id: os_cpu.h,v 1.1 2004/07/22 06:36:58 p014082819 Exp $
14
  $Revision: 1.1 $
15
----------------------------------------------------------------------
16
*/
17
 
18
/*
19
This program is free software; you can redistribute it and/or modify
20
it under the terms of the GNU General Public License as published by
21
the Free Software Foundation; either version 2 of the License, or
22
(at your option) any later version.
23
 
24
This program is distributed in the hope that it will be useful,
25
but WITHOUT ANY WARRANTY; without even the implied warranty of
26
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
GNU General Public License for more details.
28
 
29
You should have received a copy of the GNU General Public License
30
along with this program; if not, write to the Free Software
31
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32
*/
33
 
34
#ifndef OS_CPU_H
35
#define OS_CPU_H
36
 
37
#ifdef  OS_CPU_GLOBALS
38
#define OS_CPU_EXT
39
#else
40
#define OS_CPU_EXT  extern
41
#endif
42
 
43
/* Register access macros */
44
#define REG8(add) *((volatile unsigned char *)(add))
45
#define REG16(add) *((volatile unsigned short *)(add))
46
#define REG32(add) *((volatile unsigned long *)(add))
47
 
48
/*$PAGE*/
49
/*
50
*********************************************************************************************************
51
*                                              DATA TYPES
52
*                                         (Compiler Specific)
53
*********************************************************************************************************
54
*/
55
 
56
typedef unsigned char  BOOLEAN;
57
typedef unsigned char  INT8U;                    /* Unsigned  8 bit quantity                           */
58
typedef signed   char  INT8S;                    /* Signed    8 bit quantity                           */
59
typedef unsigned int   INT16U;                   /* Unsigned 16 bit quantity                           */
60
typedef signed   int   INT16S;                   /* Signed   16 bit quantity                           */
61
typedef unsigned long  INT32U;                   /* Unsigned 32 bit quantity                           */
62
typedef signed   long  INT32S;                   /* Signed   32 bit quantity                           */
63
 
64
typedef unsigned long   OS_STK;                   /* Each stack entry is 32-bits wide                  */
65
typedef unsigned long volatile   OS_CPU_SR;       /* The CPU Status Word is 32-bits wide               */
66
                                                  /* This variable MUST be volatile for proper */
67
                                                  /* operation. Refer to os_cpu_a.s for more */
68
                                                  /* details. */
69
 
70
/*
71
*********************************************************************************************************
72
*                              OpenCores OpenRISC
73
*
74
* Method #1:  Disable/Enable interrupts using simple instructions.  After critical section, interrupts
75
*             will be enabled even if they were disabled before entering the critical section.
76
*
77
* Method #2:  Disable/Enable interrupts by preserving the state of interrupts.  In other words, if
78
*             interrupts were disabled before entering the critical section, they will be disabled when
79
*             leaving the critical section.
80
*
81
* Method #3:  Disable/Enable interrupts by preserving the state of interrupts.  Generally speaking you
82
*             would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
83
*             disable interrupts.  'cpu_sr' is allocated in all of uC/OS-II's functions that need to
84
*             disable interrupts.  You would restore the interrupt disable state by copying back 'cpu_sr'
85
*             into the CPU's status register.
86
*********************************************************************************************************
87
*/
88
 
89
#define  OS_CRITICAL_METHOD    3
90
 
91
#if      OS_CRITICAL_METHOD == 3
92
#define  OS_ENTER_CRITICAL() cpu_sr = OSDisableInterrupts();
93
#define  OS_EXIT_CRITICAL()  OSEnableInterrupts(cpu_sr);
94
#endif
95
 
96
/*
97
*********************************************************************************************************
98
*                           OpenCores OpenRISC
99
*********************************************************************************************************
100
*/
101
 
102
#define  OS_STK_GROWTH        1  /* Stack grows from HIGH to LOW memory on OpenRISC  */
103
 
104
#define  OS_TASK_SW() __asm__ ("l.sys 0");\
105
                      __asm__ ("l.nop");
106
/*
107
*********************************************************************************************************
108
*                                            GLOBAL VARIABLES
109
*********************************************************************************************************
110
*/
111
 
112
/*
113
*********************************************************************************************************
114
*                                          FUNCTION PROTOTYPES
115
*********************************************************************************************************
116
*/
117
#if      OS_CRITICAL_METHOD == 3
118
OS_CPU_SR OSDisableInterrupts(void);
119
void OSEnableInterrupts(OS_CPU_SR cpu_sr);
120
#endif
121
/*
122
#ifdef  DEBUG
123
#define debug(fmt,args...) printf (fmt ,##args)
124
#else
125
#define debug(fmt,args...) __printf (fmt ,##args)
126
#endif
127
*/
128
extern void mtspr(unsigned long spr, unsigned long value);      /* For writing into SPR. */
129
extern unsigned long mfspr(unsigned long spr);                  /* For reading SPR. */
130
extern void report(unsigned long value);                        /* Prints out a value */
131
extern void exit (int i) __attribute__ ((__noreturn__));        /* return value by making a syscall */
132
//extern void __printf (const char *fmt, ...);                    /* simulator stdout */
133
extern void OSInitTick (void);                                  /* init ticker */
134
 
135
void main (void); /* Function to be called at entry point - not defined here.  */
136
 
137
/* stdio */
138
extern int getc (void);
139
extern int testc (void);
140
extern int ctrlc (void);
141
extern void putc (const char c);
142
 
143
#endif
144
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.