1 1.6 scw /* 2 1.1 is # 3 1.8 rillig # $NetBSD: netbsd060sp.S,v 1.8 2024/09/08 09:36:49 rillig Exp $ 4 1.1 is # 5 1.1 is #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 1.1 is # MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP 7 1.1 is # M68000 Hi-Performance Microprocessor Division 8 1.1 is # M68060 Software Package Production Release 9 1.1 is # 10 1.1 is # M68060 Software Package Copyright (C) 1993, 1994, 1995, 1996 Motorola Inc. 11 1.1 is # All rights reserved. 12 1.1 is # 13 1.1 is # THE SOFTWARE is provided on an "AS IS" basis and without warranty. 14 1.1 is # To the maximum extent permitted by applicable law, 15 1.1 is # MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, 16 1.1 is # INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS 17 1.1 is # FOR A PARTICULAR PURPOSE and any warranty against infringement with 18 1.1 is # regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) 19 1.1 is # and any accompanying written materials. 20 1.1 is # 21 1.1 is # To the maximum extent permitted by applicable law, 22 1.1 is # IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER 23 1.1 is # (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, 24 1.1 is # BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) 25 1.1 is # ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE. 26 1.1 is # 27 1.1 is # Motorola assumes no responsibility for the maintenance and support 28 1.1 is # of the SOFTWARE. 29 1.1 is # 30 1.1 is # You are hereby granted a copyright license to use, modify, and distribute the 31 1.1 is # SOFTWARE so long as this entire notice is retained without alteration 32 1.1 is # in any modified and/or redistributed versions, and that such modified 33 1.1 is # versions are clearly identified as such. 34 1.1 is # No licenses are granted by implication, estoppel or otherwise under any 35 1.1 is # patents or trademarks of Motorola, Inc. 36 1.1 is #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 37 1.1 is # 38 1.1 is # Derived from: 39 1.1 is # os.s 40 1.1 is # 41 1.1 is # This file contains: 42 1.1 is # - example "Call-Out"s required by both the ISP and FPSP. 43 1.1 is # 44 1.6 scw */ 45 1.1 is 46 1.6 scw #include <machine/asm.h> 47 1.6 scw 48 1.7 scw #include "assym.h" 49 1.7 scw 50 1.6 scw /* 51 1.1 is # 52 1.1 is # make the copyright notice appear in the binary: 53 1.1 is # 54 1.6 scw */ 55 1.6 scw #include "copyright.S" 56 1.1 is 57 1.6 scw /* 58 1.1 is ################################# 59 1.1 is # EXAMPLE CALL-OUTS # 60 1.1 is # # 61 1.1 is # _060_dmem_write() # 62 1.1 is # _060_dmem_read() # 63 1.1 is # _060_imem_read() # 64 1.1 is # _060_dmem_read_byte() # 65 1.1 is # _060_dmem_read_word() # 66 1.1 is # _060_dmem_read_long() # 67 1.1 is # _060_imem_read_word() # 68 1.1 is # _060_imem_read_long() # 69 1.1 is # _060_dmem_write_byte() # 70 1.1 is # _060_dmem_write_word() # 71 1.1 is # _060_dmem_write_long() # 72 1.1 is # # 73 1.1 is # _060_real_trace() # 74 1.1 is # _060_real_access() # 75 1.1 is ################################# 76 1.6 scw */ 77 1.1 is 78 1.6 scw /* 79 1.1 is # 80 1.1 is # Each IO routine checks to see if the memory write/read is to/from user 81 1.1 is # or supervisor application space. The examples below use simple "move" 82 1.1 is # instructions for supervisor mode applications and call _copyin()/_copyout() 83 1.1 is # for user mode applications. 84 1.1 is # When installing the 060SP, the _copyin()/_copyout() equivalents for a 85 1.1 is # given operating system should be substituted. 86 1.1 is # 87 1.1 is # The addresses within the 060SP are guaranteed to be on the stack. 88 1.1 is # The result is that Unix processes are allowed to sleep as a consequence 89 1.1 is # of a page fault during a _copyout. 90 1.1 is # 91 1.6 scw */ 92 1.1 is 93 1.6 scw /* 94 1.1 is # 95 1.1 is # _060_dmem_write(): 96 1.1 is # 97 1.1 is # Writes to data memory while in supervisor mode. 98 1.1 is # 99 1.1 is # INPUTS: 100 1.1 is # a0 - supervisor source address 101 1.1 is # a1 - user destination address 102 1.1 is # d0 - number of bytes to write 103 1.1 is # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode 104 1.1 is # OUTPUTS: 105 1.1 is # d1 - 0 = success, !0 = failure 106 1.1 is # 107 1.6 scw */ 108 1.6 scw ASENTRY_NOPROFILE(_060_dmem_write) 109 1.6 scw btst #0x5,%a6@(0x4) |# check for supervisor state 110 1.1 is beqs user_write 111 1.1 is super_write: 112 1.6 scw moveb %a0@+,%a1@+ |# copy 1 byte 113 1.6 scw subql #0x1,%d0 |# decr byte counter 114 1.2 is bnes super_write |# quit if ctr = 0 115 1.6 scw clrl %d1 |# return success 116 1.1 is rts 117 1.1 is user_write: 118 1.6 scw movel %d0,%sp@- |# pass: counter 119 1.6 scw movel %a1,%sp@- |# pass: user dst 120 1.6 scw movel %a0,%sp@- |# pass: supervisor src 121 1.6 scw bsrl _C_LABEL(copyout) |# write byte to user mem 122 1.6 scw movel %d0,%d1 |# return success 123 1.6 scw addl #0xc,%sp |# clear 3 lw params 124 1.1 is rts 125 1.1 is 126 1.6 scw /* 127 1.1 is # 128 1.1 is # _060_imem_read(), _060_dmem_read(): 129 1.1 is # 130 1.1 is # Reads from data/instruction memory while in supervisor mode. 131 1.1 is # 132 1.1 is # INPUTS: 133 1.1 is # a0 - user source address 134 1.1 is # a1 - supervisor destination address 135 1.1 is # d0 - number of bytes to read 136 1.1 is # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode 137 1.1 is # OUTPUTS: 138 1.1 is # d1 - 0 = success, !0 = failure 139 1.1 is # 140 1.6 scw */ 141 1.6 scw ASENTRY_NOPROFILE(_060_imem_read) 142 1.6 scw ASENTRY_NOPROFILE(_060_dmem_read) 143 1.6 scw btst #0x5,%a6@(0x4) |# check for supervisor state 144 1.1 is beqs user_read 145 1.1 is super_read: 146 1.6 scw moveb %a0@+,%a1@+ |# copy 1 byte 147 1.6 scw subql #0x1,%d0 |# decr byte counter 148 1.2 is bnes super_read |# quit if ctr = 0 149 1.6 scw clrl %d1 |# return success 150 1.1 is rts 151 1.1 is user_read: 152 1.6 scw movel %d0,%sp@- |# pass: counter 153 1.6 scw movel %a1,%sp@- |# pass: super dst 154 1.6 scw movel %a0,%sp@- |# pass: user src 155 1.6 scw bsrl _C_LABEL(copyin) |# read byte from user mem 156 1.6 scw movel %d0,%d1 |# return success 157 1.6 scw addl #0xc,%sp |# clear 3 lw params 158 1.1 is rts 159 1.1 is 160 1.6 scw /* 161 1.1 is # 162 1.1 is # _060_dmem_read_byte(): 163 1.1 is # 164 1.1 is # Read a data byte from user memory. 165 1.1 is # 166 1.1 is # INPUTS: 167 1.1 is # a0 - user source address 168 1.1 is # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode 169 1.1 is # OUTPUTS: 170 1.1 is # d0 - data byte in d0 171 1.1 is # d1 - 0 = success, !0 = failure 172 1.1 is # 173 1.6 scw */ 174 1.6 scw ASENTRY_NOPROFILE(_060_dmem_read_byte) 175 1.6 scw clrl %d1 |# return success 176 1.6 scw clrl %d0 |# clear whole longword 177 1.6 scw btst #0x5,%a6@(0x4) |# check for supervisor state 178 1.4 is bnes dmrbs |# supervisor 179 1.1 is dmrbu: 180 1.6 scw movl _C_LABEL(curpcb),%a1 | fault handler 181 1.7 scw movl #Lferr,%a1@(PCB_ONFAULT)| set it 182 1.6 scw movsb %a0@,%d0 183 1.4 is bra Lfdone 184 1.4 is 185 1.1 is dmrbs: 186 1.6 scw moveb %a0@,%d0 |# fetch super byte 187 1.1 is rts 188 1.1 is 189 1.6 scw /* 190 1.1 is # 191 1.1 is # _060_imem_read_word(): 192 1.1 is # Read an instruction word from user memory. 193 1.1 is # 194 1.1 is # _060_dmem_read_word(): 195 1.1 is # Read a data word from user memory. 196 1.1 is # 197 1.1 is # INPUTS: 198 1.1 is # a0 - user source address 199 1.1 is # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode 200 1.1 is # OUTPUTS: 201 1.1 is # d0 - data word in d0 202 1.1 is # d1 - 0 = success, !0 = failure 203 1.1 is # 204 1.6 scw */ 205 1.6 scw ASENTRY_NOPROFILE(_060_imem_read_word) 206 1.6 scw ASENTRY_NOPROFILE(_060_dmem_read_word) 207 1.6 scw clrl %d1 |# return success 208 1.6 scw clrl %d0 |# clear whole longword 209 1.6 scw btst #0x5,%a6@(0x4) |# check for supervisor state 210 1.4 is bnes dmrws |# supervisor 211 1.1 is dmrwu: 212 1.6 scw movl _C_LABEL(curpcb),%a1 | fault handler 213 1.7 scw movl #Lferr,%a1@(PCB_ONFAULT)| set it 214 1.6 scw movsw %a0@,%d0 215 1.4 is bra Lfdone 216 1.1 is dmrws: 217 1.6 scw movew %a0@,%d0 |# fetch super word 218 1.1 is rts 219 1.1 is 220 1.6 scw /* 221 1.8 rillig # 222 1.1 is # _060_imem_read_long(): 223 1.1 is # Read an instruction longword from user memory. 224 1.1 is # 225 1.1 is # _060_dmem_read_long(): 226 1.8 rillig # Read a data longword from user memory. 227 1.8 rillig # 228 1.1 is # 229 1.1 is # INPUTS: 230 1.1 is # a0 - user source address 231 1.1 is # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode 232 1.1 is # OUTPUTS: 233 1.1 is # d0 - data longword in d0 234 1.1 is # d1 - 0 = success, !0 = failure 235 1.1 is # 236 1.6 scw */ 237 1.6 scw ASENTRY_NOPROFILE(_060_imem_read_long) 238 1.6 scw ASENTRY_NOPROFILE(_060_dmem_read_long) 239 1.6 scw clrl %d1 |# return success 240 1.6 scw btst #0x5,%a6@(0x4) |# check for supervisor state 241 1.4 is bnes dmrls |# supervisor 242 1.1 is dmrlu: 243 1.6 scw movl _C_LABEL(curpcb),%a1 | fault handler 244 1.7 scw movl #Lferr,%a1@(PCB_ONFAULT)| set it 245 1.6 scw movsl %a0@,%d0 246 1.4 is bra Lfdone 247 1.1 is dmrls: 248 1.6 scw movel %a0@,%d0 |# fetch super longword 249 1.1 is rts 250 1.1 is 251 1.6 scw /* 252 1.1 is # 253 1.1 is # _060_dmem_write_byte(): 254 1.1 is # 255 1.1 is # Write a data byte to user memory. 256 1.1 is # 257 1.1 is # INPUTS: 258 1.1 is # a0 - user destination address 259 1.1 is # d0 - data byte in d0 260 1.1 is # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode 261 1.1 is # OUTPUTS: 262 1.1 is # d1 - 0 = success, !0 = failure 263 1.1 is # 264 1.6 scw */ 265 1.6 scw ASENTRY_NOPROFILE(_060_dmem_write_byte) 266 1.6 scw clrl %d1 |# return success 267 1.6 scw btst #0x5,%a6@(0x4) |# check for supervisor state 268 1.4 is bnes dmwbs |# supervisor 269 1.1 is dmwbu: 270 1.6 scw movl _C_LABEL(curpcb),%a1 | fault handler 271 1.7 scw movl #Lferr,%a1@(PCB_ONFAULT)| set it 272 1.6 scw movsb %d0,%a0@ 273 1.4 is bra Lfdone 274 1.1 is dmwbs: 275 1.6 scw moveb %d0,%a0@ |# store super byte 276 1.1 is rts 277 1.1 is 278 1.6 scw /* 279 1.1 is # 280 1.1 is # _060_dmem_write_word(): 281 1.1 is # 282 1.1 is # Write a data word to user memory. 283 1.1 is # 284 1.1 is # INPUTS: 285 1.1 is # a0 - user destination address 286 1.1 is # d0 - data word in d0 287 1.1 is # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode 288 1.1 is # OUTPUTS: 289 1.1 is # d1 - 0 = success, !0 = failure 290 1.1 is # 291 1.6 scw */ 292 1.6 scw ASENTRY_NOPROFILE(_060_dmem_write_word) 293 1.6 scw clrl %d1 |# return success 294 1.6 scw btst #0x5,%a6@(0x4) |# check for supervisor state 295 1.4 is bnes dmwws |# supervisor 296 1.1 is dmwwu: 297 1.6 scw movl _C_LABEL(curpcb),%a1 | fault handler 298 1.7 scw movl #Lferr,%a1@(PCB_ONFAULT)| set it 299 1.6 scw movsw %d0,%a0@ 300 1.4 is bra Lfdone 301 1.1 is dmwws: 302 1.6 scw movew %d0,%a0@ |# store super word 303 1.1 is rts 304 1.1 is 305 1.6 scw /* 306 1.1 is # 307 1.1 is # _060_dmem_write_long(): 308 1.1 is # 309 1.1 is # Write a data longword to user memory. 310 1.1 is # 311 1.1 is # INPUTS: 312 1.1 is # a0 - user destination address 313 1.1 is # d0 - data longword in d0 314 1.1 is # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode 315 1.1 is # OUTPUTS: 316 1.1 is # d1 - 0 = success, !0 = failure 317 1.1 is # 318 1.6 scw */ 319 1.6 scw ASENTRY_NOPROFILE(_060_dmem_write_long) 320 1.6 scw clrl %d1 |# return success 321 1.6 scw btst #0x5,%a6@(0x4) |# check for supervisor state 322 1.4 is bnes dmwls |# supervisor 323 1.1 is dmwlu: 324 1.6 scw movl _C_LABEL(curpcb),%a1 | fault handler 325 1.7 scw movl #Lferr,%a1@(PCB_ONFAULT)| set it 326 1.6 scw movsl %d0,%a0@ 327 1.4 is bra Lfdone 328 1.4 is dmwls: 329 1.6 scw movel %d0,%a0@ |# store super longword 330 1.1 is rts 331 1.4 is 332 1.6 scw |############################################################################ 333 1.4 is Lferr: 334 1.6 scw moveq #-1,%d1 335 1.4 is Lfdone: 336 1.7 scw clrl %a1@(PCB_ONFAULT) | clear fault handler 337 1.1 is rts 338 1.1 is 339 1.6 scw |############################################################################ 340 1.1 is 341 1.6 scw /* 342 1.1 is # 343 1.1 is # _060_real_trace(): 344 1.1 is # 345 1.1 is # This is the exit point for the 060FPSP when an instruction is being traced 346 1.1 is # and there are no other higher priority exceptions pending for this instruction 347 1.1 is # or they have already been processed. 348 1.1 is # 349 1.1 is # The sample code below simply executes an "rte". 350 1.1 is # 351 1.6 scw */ 352 1.6 scw ASENTRY_NOPROFILE(_060_real_trace) 353 1.6 scw jra _C_LABEL(trace) 354 1.1 is 355 1.6 scw /* 356 1.1 is # 357 1.1 is # _060_real_access(): 358 1.1 is # 359 1.1 is # This is the exit point for the 060FPSP when an access error exception 360 1.1 is # is encountered. The routine below should point to the operating system 361 1.1 is # handler for access error exceptions. The exception stack frame is an 362 1.1 is # 8-word access error frame. 363 1.1 is # 364 1.2 is # We jump directly to the 68060 buserr handler. 365 1.2 is # If we had a sane ld, we could use use that entry point directly... 366 1.1 is # 367 1.6 scw */ 368 1.6 scw ASENTRY_NOPROFILE(_060_real_access) 369 1.6 scw jra _C_LABEL(buserr60) 370 1.1 is 371 1.6 scw #include "inetbsd.S" 372 1.6 scw #include "fnetbsd.S" 373