Mercurial > ecos
annotate packages/kernel/current/include/bitmap.hxx @ 3292:7f8e529b4d82 default tip
Fix FREESCALE_EDMA_NBYTES_MLOFFYES_MLOFF() so it works with negative offsets.
| author | vae |
|---|---|
| date | Wed, 29 Apr 2015 23:31:48 +0000 |
| parents | 74dbf4c3f2e1 |
| children |
| rev | line source |
|---|---|
| 0 | 1 #ifndef CYGONCE_KERNEL_BITMAP_HXX |
| 2 #define CYGONCE_KERNEL_BITMAP_HXX | |
| 3 | |
| 4 //========================================================================== | |
| 5 // | |
| 2 | 6 // bitmap.hxx |
| 0 | 7 // |
| 2 | 8 // Bitmap scheduler class declaration(s) |
| 0 | 9 // |
| 10 //========================================================================== | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
11 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
12 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
13 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
15 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
16 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
17 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
18 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
19 // version. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
20 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
21 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
22 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
23 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
24 // for more details. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
25 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
26 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
27 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
28 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
29 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
30 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
31 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
32 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
33 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
34 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
35 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
36 // General Public License v2. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
37 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
38 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
39 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
40 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2348
diff
changeset
|
41 // ####ECOSGPLCOPYRIGHTEND#### |
| 0 | 42 //========================================================================== |
| 43 //#####DESCRIPTIONBEGIN#### | |
| 44 // | |
| 2 | 45 // Author(s): nickg |
| 46 // Contributors: nickg | |
| 47 // Date: 1997-09-10 | |
| 48 // Purpose: Define bitmap scheduler implementation | |
| 49 // Description: The classes defined here are used as base classes | |
| 0 | 50 // by the common classes that define schedulers and thread |
| 51 // things. | |
| 52 // Usage: Included according to configuration by | |
| 53 // <cyg/kernel/sched.hxx> | |
| 54 // | |
| 55 //####DESCRIPTIONEND#### | |
| 56 // | |
| 57 //========================================================================== | |
| 58 | |
| 59 #include <cyg/kernel/ktypes.h> | |
| 60 | |
| 61 // ------------------------------------------------------------------------- | |
| 62 // The macro CYGNUM_KERNEL_SCHED_BITMAP_SIZE contains the number of bits | |
| 63 // that the scheduler bitmap should contain. It is derived from the number | |
| 64 // of threads that the system is allowed to use during configuration. | |
| 65 | |
| 66 #ifndef CYGNUM_KERNEL_SCHED_BITMAP_SIZE | |
| 67 #define CYGNUM_KERNEL_SCHED_BITMAP_SIZE 32 | |
| 68 #endif | |
| 69 | |
| 70 #if CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 8 | |
| 71 typedef cyg_ucount8 cyg_sched_bitmap; | |
| 72 #elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 16 | |
| 73 typedef cyg_ucount16 cyg_sched_bitmap; | |
| 74 #elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 32 | |
| 75 typedef cyg_ucount32 cyg_sched_bitmap; | |
| 76 #else | |
| 77 #error Bitmaps greater than 32 bits not currently allowed | |
| 78 #endif | |
| 79 | |
| 80 // ------------------------------------------------------------------------- | |
| 81 // Customize the scheduler | |
| 82 | |
| 83 #define CYGIMP_THREAD_PRIORITY 1 | |
| 84 | |
| 85 #define CYG_THREAD_MIN_PRIORITY (CYGNUM_KERNEL_SCHED_BITMAP_SIZE-1) | |
| 86 #define CYG_THREAD_MAX_PRIORITY 0 | |
| 87 | |
| 88 // set default scheduling info value for thread constructors. | |
| 89 #define CYG_SCHED_DEFAULT_INFO CYG_THREAD_MAX_PRIORITY | |
| 90 | |
| 91 // ------------------------------------------------------------------------- | |
| 92 // This class contains the implementation details of the scheduler, and | |
| 93 // provides a standard API for accessing it. | |
| 94 | |
| 95 class Cyg_Scheduler_Implementation | |
| 96 : public Cyg_Scheduler_Base | |
| 97 { | |
| 98 friend class Cyg_ThreadQueue_Implementation; | |
| 99 friend class Cyg_SchedThread_Implementation; | |
| 100 | |
| 101 cyg_sched_bitmap run_queue; | |
| 102 | |
| 103 Cyg_Thread *thread_table[CYGNUM_KERNEL_SCHED_BITMAP_SIZE]; | |
| 104 | |
| 105 | |
| 106 protected: | |
| 107 | |
| 108 Cyg_Scheduler_Implementation(); // Constructor | |
| 109 | |
| 110 // The following functions provide the scheduler implementation | |
| 111 // interface to the Cyg_Scheduler class. These are protected | |
| 112 // so that only the scheduler can call them. | |
| 113 | |
| 114 // choose a new thread | |
| 115 Cyg_Thread *schedule(); | |
| 116 | |
| 117 // make thread schedulable | |
| 118 void add_thread(Cyg_Thread *thread); | |
| 119 | |
| 120 // make thread un-schedulable | |
| 121 void rem_thread(Cyg_Thread *thread); | |
| 122 | |
| 123 // register thread with scheduler | |
| 124 void register_thread(Cyg_Thread *thread); | |
| 125 | |
| 126 // deregister thread | |
| 127 void deregister_thread(Cyg_Thread *thread); | |
| 128 | |
| 129 // Test the given priority for uniqueness | |
| 130 cyg_bool unique( cyg_priority priority); | |
|
177
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
132
diff
changeset
|
131 |
|
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
132
diff
changeset
|
132 public: |
|
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
132
diff
changeset
|
133 void set_idle_thread( Cyg_Thread *thread, HAL_SMP_CPU_TYPE cpu ); |
| 0 | 134 |
| 135 }; | |
| 136 | |
| 137 // ------------------------------------------------------------------------- | |
| 138 // Scheduler thread implementation. | |
| 139 // This class provides the implementation of the scheduler specific parts | |
| 140 // of each thread. | |
| 141 | |
| 142 class Cyg_SchedThread_Implementation | |
| 143 { | |
| 144 friend class Cyg_Scheduler_Implementation; | |
| 145 friend class Cyg_ThreadQueue_Implementation; | |
| 146 | |
| 147 protected: | |
| 148 | |
| 149 cyg_priority priority; // current thread priority | |
| 150 | |
| 151 Cyg_SchedThread_Implementation(CYG_ADDRWORD sched_info); | |
| 152 | |
| 153 void yield(); // Yield CPU to next thread | |
| 154 | |
| 2 | 155 // These are not applicable in a bitmap scheduler; placeholders: |
| 156 inline void rotate_queue( cyg_priority pri ) { }; | |
| 157 inline void to_queue_head( void ) { }; | |
| 2348 | 158 |
| 159 inline void timeslice_save() {}; | |
| 160 inline void timeslice_restore() {}; | |
| 161 inline void timeslice_reset() {}; | |
| 162 | |
| 0 | 163 }; |
| 164 | |
| 165 // ------------------------------------------------------------------------- | |
| 166 // Thread queue implementation. | |
| 167 // This class provides the (scheduler specific) implementation of the | |
| 168 // thread queue class. | |
| 169 | |
| 170 class Cyg_ThreadQueue_Implementation | |
| 171 { | |
| 172 cyg_sched_bitmap wait_queue; | |
| 173 | |
| 174 protected: | |
| 175 | |
| 176 // API used by Cyg_ThreadQueue | |
| 177 | |
| 178 Cyg_ThreadQueue_Implementation(); // Constructor | |
| 179 | |
| 180 // Add thread to queue | |
| 181 void enqueue(Cyg_Thread *thread); | |
| 182 | |
| 183 // return first thread on queue | |
| 184 Cyg_Thread *highpri(); | |
| 185 | |
| 186 // remove first thread on queue | |
| 187 Cyg_Thread *dequeue(); | |
| 188 | |
| 189 // remove specified thread from queue | |
| 190 void remove(Cyg_Thread *thread); | |
| 191 | |
| 192 // test if queue is empty | |
| 193 cyg_bool empty(); | |
| 194 | |
| 195 }; | |
| 196 | |
| 197 inline cyg_bool Cyg_ThreadQueue_Implementation::empty() | |
| 198 { | |
| 199 return wait_queue == 0; | |
| 200 } | |
| 201 | |
| 202 // ------------------------------------------------------------------------- | |
| 203 | |
| 204 #endif // ifndef CYGONCE_KERNEL_BITMAP_HXX | |
| 205 // EOF bitmap.hxx |
