| 1 |
301 |
jshamlet |
; Copyright (c)2022 Jeremy Seth Henry
|
| 2 |
|
|
; All rights reserved.
|
| 3 |
|
|
;
|
| 4 |
|
|
; Redistribution and use in source and binary forms, with or without
|
| 5 |
|
|
; modification, are permitted provided that the following conditions are met:
|
| 6 |
|
|
; * Redistributions of source code must retain the above copyright
|
| 7 |
|
|
; notice, this list of conditions and the following disclaimer.
|
| 8 |
|
|
; * Redistributions in binary form must reproduce the above copyright
|
| 9 |
|
|
; notice, this list of conditions and the following disclaimer in the
|
| 10 |
|
|
; documentation and/or other materials provided with the distribution,
|
| 11 |
|
|
; where applicable (as part of a user interface, debugging port, etc.)
|
| 12 |
|
|
;
|
| 13 |
|
|
; THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
|
| 14 |
|
|
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| 15 |
|
|
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 16 |
|
|
; DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
|
| 17 |
|
|
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
| 18 |
|
|
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
| 19 |
|
|
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 20 |
|
|
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 21 |
|
|
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| 22 |
|
|
; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 23 |
|
|
;
|
| 24 |
|
|
;------------------------------------------------------------------------------
|
| 25 |
|
|
; taskmgr_config.s
|
| 26 |
|
|
;
|
| 27 |
|
|
; Main Manager task specific constants (this must precede taskmgr_const.s)
|
| 28 |
|
|
;
|
| 29 |
|
|
; Revision History
|
| 30 |
|
|
; Author Date Change
|
| 31 |
|
|
;---------------- -------- ----------------------------------------------------
|
| 32 |
|
|
; Seth Henry 7/15/22 Initial Release
|
| 33 |
|
|
;------------------------------------------------------------------------------
|
| 34 |
|
|
|
| 35 |
|
|
;------------------------------------------------------------------------------
|
| 36 |
|
|
; Task Management Constants
|
| 37 |
|
|
;------------------------------------------------------------------------------
|
| 38 |
|
|
.DEFINE MAX_TASK_TIMESLICE $FA ; Preemption Time slice is 250uS
|
| 39 |
|
|
.DEFINE TASK_COUNT 2 ; Number of defined tasks
|
| 40 |
|
|
;------------------------------------------------------------------------------
|
| 41 |
|
|
|
| 42 |
|
|
;------------------------------------------------------------------------------
|
| 43 |
|
|
; Task RAM Placement Constants
|
| 44 |
|
|
;------------------------------------------------------------------------------
|
| 45 |
|
|
; Low memory regions (15:0)
|
| 46 |
|
|
; 0 - System Memory
|
| 47 |
|
|
; 1 - Task 0 Private Memory
|
| 48 |
|
|
; 2 - Task 1 Private Memory
|
| 49 |
|
|
; 3-15 - (Unused)
|
| 50 |
|
|
|
| 51 |
|
|
; High memory regions (31:16)
|
| 52 |
|
|
; 16-20 - (Unused)
|
| 53 |
|
|
; 30 - Task 0 Stack Memory
|
| 54 |
|
|
; 31 - Task 1 Stack Memory
|
| 55 |
|
|
|
| 56 |
|
|
; Assign each memory region within the 32 write protect blocks using 31 to 0
|
| 57 |
|
|
; Note that regions from 15 to 0 are "low" memory (don't need to be adjusted
|
| 58 |
|
|
; for the mask calculation) while regions from 31 to 16 are "high" memory, and
|
| 59 |
|
|
; should have 16 subtracted to avoid overflowing a 16-bit value.
|
| 60 |
|
|
;
|
| 61 |
|
|
; Note that this implies a maximum task count of 15, as at least one region is
|
| 62 |
|
|
; required for the task manager itself, unless an additional BRAM is allocated
|
| 63 |
|
|
; for the task manager.
|
| 64 |
|
|
|
| 65 |
|
|
; Variable Memory regions (15:0)
|
| 66 |
|
|
.DEFINE SYSTEM_VAR_RGN 0
|
| 67 |
|
|
.DEFINE TASK0_VAR_RGN 1
|
| 68 |
|
|
.DEFINE TASK1_VAR_RGN 2
|
| 69 |
|
|
|
| 70 |
|
|
; Stack Memory regions (31:16)
|
| 71 |
|
|
.DEFINE TASK0_STACK_RGN 30
|
| 72 |
|
|
.DEFINE TASK1_STACK_RGN 31
|
| 73 |
|
|
|
| 74 |
|
|
; Note that the WPR masks are handled here in order to add flexibility, such as
|
| 75 |
|
|
; adding a data buffer region in "high" memory or otherwise configuring a
|
| 76 |
|
|
; task's WPR for its memory needs
|
| 77 |
|
|
;
|
| 78 |
|
|
; Note that, because of the nature of the WPR, additional memory regions, such
|
| 79 |
|
|
; as a while region to handle block transfers, can be added by by logically
|
| 80 |
|
|
; OR'ing the region masks together. Note that the resultant line does need to
|
| 81 |
|
|
; be on one line or the assembler won't process it correctly.
|
| 82 |
|
|
; ie .DEFINE TASK_VAR_MASK (2^TASK2_VAR_RGN) | (2^BUF_RGN0) | (2^BUF_RGN1)
|
| 83 |
|
|
|
| 84 |
|
|
; Note that the assembler can't generate a 32-bit value for the mask, so for values
|
| 85 |
|
|
; greater than 15, an offset of 16 is subtracted and the mask value. Thus, there
|
| 86 |
|
|
; is a "low mask" for regions 0-15 and a "high mask" for regions 16-31.
|
| 87 |
|
|
.DEFINE HIGH_MEM_OFFSET 16
|
| 88 |
|
|
|
| 89 |
|
|
.DEFINE TASK0_WPR_LOW 2^TASK0_VAR_RGN
|
| 90 |
|
|
.DEFINE TASK1_WPR_LOW 2^TASK1_VAR_RGN
|
| 91 |
|
|
|
| 92 |
|
|
.DEFINE TASK0_WPR_HIGH 2^( TASK0_STACK_RGN - HIGH_MEM_OFFSET )
|
| 93 |
|
|
.DEFINE TASK1_WPR_HIGH 2^( TASK1_STACK_RGN - HIGH_MEM_OFFSET )
|
| 94 |
|
|
|
| 95 |
|
|
; Allocate the variable structures in memory. Note that WP_Rgn_Size is also
|
| 96 |
|
|
; used in taskmgr_const.s to compute the address of each task's stack start
|
| 97 |
|
|
; and end
|
| 98 |
|
|
.DEFINE WP_Rgn_Size RAM_Size / RAM_Partitions ; From sys_hw_map.s
|
| 99 |
|
|
|
| 100 |
|
|
.DEFINE SYSTEM_VARMEM RAM_Address + ( SYSTEM_VAR_RGN * WP_Rgn_Size )
|
| 101 |
|
|
.DEFINE TASK0_VARMEM RAM_Address + ( TASK0_VAR_RGN * WP_Rgn_Size )
|
| 102 |
|
|
.DEFINE TASK1_VARMEM RAM_Address + ( TASK1_VAR_RGN * WP_Rgn_Size )
|
| 103 |
|
|
|
| 104 |
|
|
;------------------------------------------------------------------------------
|
| 105 |
|
|
|
| 106 |
|
|
;------------------------------------------------------------------------------
|
| 107 |
|
|
; Task ROM Placement Constants
|
| 108 |
|
|
; Note that the task blocks define the initial location for each task's code
|
| 109 |
|
|
; and data. If a region overflows, these constants will need to be adjusted.
|
| 110 |
|
|
;------------------------------------------------------------------------------
|
| 111 |
|
|
.DEFINE BOOT_BLOCK $8000 ; Start of ROM
|
| 112 |
|
|
.DEFINE DATA_BLOCK $8800 ; ROM Data
|
| 113 |
|
|
.DEFINE TASK0_BLOCK $9000 ; Task 0
|
| 114 |
|
|
.DEFINE TASK1_BLOCK $A000 ; Task 1
|
| 115 |
|
|
;------------------------------------------------------------------------------
|
| 116 |
|
|
|
| 117 |
|
|
;------------------------------------------------------------------------------
|
| 118 |
|
|
; Task I/O Write Qualification Constants
|
| 119 |
|
|
;------------------------------------------------------------------------------
|
| 120 |
|
|
.DEFINE TASK0_WQL $00
|
| 121 |
|
|
.DEFINE TASK1_WQL $00
|
| 122 |
|
|
;------------------------------------------------------------------------------
|
| 123 |
|
|
|
| 124 |
|
|
;------------------------------------------------------------------------------
|
| 125 |
|
|
; External I/O Interrupt Flag Macros - processed from within
|
| 126 |
|
|
; CHECK_EXTERNAL_IO_INTS
|
| 127 |
|
|
;
|
| 128 |
|
|
; Note that the relevant tasks should define macros allowing access to their
|
| 129 |
|
|
; ISR flag variables and/or other code that should run in supervisor context
|
| 130 |
|
|
; when the relevant interrupt is triggered.
|
| 131 |
|
|
;
|
| 132 |
|
|
; Note also that only R1 and R0 are safe to use when setting flags. Avoid R7-R2
|
| 133 |
|
|
; as R3 and R2 are keeping track of flags and R4 through R7 aren't backed up
|
| 134 |
|
|
;------------------------------------------------------------------------------
|
| 135 |
|
|
|
| 136 |
|
|
; 0 = (unused)
|
| 137 |
|
|
; 1 = (unused)
|
| 138 |
|
|
; 2 = (unused)
|
| 139 |
|
|
; 3 = (unused)
|
| 140 |
|
|
; 4 = (unused)
|
| 141 |
|
|
; 5 = (unused)
|
| 142 |
|
|
; 6 = (unused)
|
| 143 |
|
|
; 7 = (unused)
|
| 144 |
|
|
; 8 = (unused)
|
| 145 |
|
|
; 9 = (unused)
|
| 146 |
|
|
; 10 = (unused)
|
| 147 |
|
|
; 11 = (unused)
|
| 148 |
|
|
; 12 = (unused)
|
| 149 |
|
|
; 13 = (unused)
|
| 150 |
|
|
; 14 = (unused)
|
| 151 |
|
|
; 15 = (unused)
|
| 152 |
|
|
|
| 153 |
|
|
; For 8-bit external interrupt manager, only use the _L constant
|
| 154 |
|
|
.DEFINE EXT_INTERRUPT_EN_L $00
|
| 155 |
|
|
.DEFINE EXT_INTERRUPT_EN_H $00
|
| 156 |
|
|
|
| 157 |
|
|
; These macros are valid for both the 8 and 16-bit interrupt managers
|
| 158 |
|
|
.MACRO SET_INT0_FLAGS
|
| 159 |
|
|
.ENDM
|
| 160 |
|
|
|
| 161 |
|
|
.MACRO SET_INT1_FLAGS
|
| 162 |
|
|
.ENDM
|
| 163 |
|
|
|
| 164 |
|
|
.MACRO SET_INT2_FLAGS
|
| 165 |
|
|
.ENDM
|
| 166 |
|
|
|
| 167 |
|
|
.MACRO SET_INT3_FLAGS
|
| 168 |
|
|
.ENDM
|
| 169 |
|
|
|
| 170 |
|
|
.MACRO SET_INT4_FLAGS
|
| 171 |
|
|
.ENDM
|
| 172 |
|
|
|
| 173 |
|
|
.MACRO SET_INT5_FLAGS
|
| 174 |
|
|
.ENDM
|
| 175 |
|
|
|
| 176 |
|
|
.MACRO SET_INT6_FLAGS
|
| 177 |
|
|
.ENDM
|
| 178 |
|
|
|
| 179 |
|
|
.MACRO SET_INT7_FLAGS
|
| 180 |
|
|
.ENDM
|
| 181 |
|
|
|
| 182 |
|
|
; These macros are only valid for the 16-bit interrupt manager
|
| 183 |
|
|
.MACRO SET_INT8_FLAGS
|
| 184 |
|
|
.ENDM
|
| 185 |
|
|
|
| 186 |
|
|
.MACRO SET_INT9_FLAGS
|
| 187 |
|
|
.ENDM
|
| 188 |
|
|
|
| 189 |
|
|
.MACRO SET_INT10_FLAGS
|
| 190 |
|
|
.ENDM
|
| 191 |
|
|
|
| 192 |
|
|
.MACRO SET_INT11_FLAGS
|
| 193 |
|
|
.ENDM
|
| 194 |
|
|
|
| 195 |
|
|
.MACRO SET_INT12_FLAGS
|
| 196 |
|
|
.ENDM
|
| 197 |
|
|
|
| 198 |
|
|
.MACRO SET_INT13_FLAGS
|
| 199 |
|
|
.ENDM
|
| 200 |
|
|
|
| 201 |
|
|
.MACRO SET_INT14_FLAGS
|
| 202 |
|
|
.ENDM
|
| 203 |
|
|
|
| 204 |
|
|
.MACRO SET_INT15_FLAGS
|
| 205 |
|
|
.ENDM
|
| 206 |
|
|
|
| 207 |
|
|
;------------------------------------------------------------------------------
|