Annotation of sys/arch/m68k/060sp/os.s, Revision 1.1
1.1 ! nbrk 1: #
! 2: # $OpenBSD: os.s,v 1.2 1996/05/30 22:15:04 niklas Exp $
! 3: # $NetBSD: os.s,v 1.2 1996/05/15 19:49:06 is Exp $
! 4: #
! 5:
! 6: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! 7: # MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
! 8: # M68000 Hi-Performance Microprocessor Division
! 9: # M68060 Software Package Production Release
! 10: #
! 11: # M68060 Software Package Copyright (C) 1993, 1994, 1995, 1996 Motorola Inc.
! 12: # All rights reserved.
! 13: #
! 14: # THE SOFTWARE is provided on an "AS IS" basis and without warranty.
! 15: # To the maximum extent permitted by applicable law,
! 16: # MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
! 17: # INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS
! 18: # FOR A PARTICULAR PURPOSE and any warranty against infringement with
! 19: # regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
! 20: # and any accompanying written materials.
! 21: #
! 22: # To the maximum extent permitted by applicable law,
! 23: # IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
! 24: # (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
! 25: # BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS)
! 26: # ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
! 27: #
! 28: # Motorola assumes no responsibility for the maintenance and support
! 29: # of the SOFTWARE.
! 30: #
! 31: # You are hereby granted a copyright license to use, modify, and distribute the
! 32: # SOFTWARE so long as this entire notice is retained without alteration
! 33: # in any modified and/or redistributed versions, and that such modified
! 34: # versions are clearly identified as such.
! 35: # No licenses are granted by implication, estoppel or otherwise under any
! 36: # patents or trademarks of Motorola, Inc.
! 37: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! 38:
! 39: #
! 40: # os.s
! 41: #
! 42: # This file contains:
! 43: # - example "Call-Out"s required by both the ISP and FPSP.
! 44: #
! 45:
! 46:
! 47: #################################
! 48: # EXAMPLE CALL-OUTS #
! 49: # #
! 50: # _060_dmem_write() #
! 51: # _060_dmem_read() #
! 52: # _060_imem_read() #
! 53: # _060_dmem_read_byte() #
! 54: # _060_dmem_read_word() #
! 55: # _060_dmem_read_long() #
! 56: # _060_imem_read_word() #
! 57: # _060_imem_read_long() #
! 58: # _060_dmem_write_byte() #
! 59: # _060_dmem_write_word() #
! 60: # _060_dmem_write_long() #
! 61: # #
! 62: # _060_real_trace() #
! 63: # _060_real_access() #
! 64: #################################
! 65:
! 66: #
! 67: # Each IO routine checks to see if the memory write/read is to/from user
! 68: # or supervisor application space. The examples below use simple "move"
! 69: # instructions for supervisor mode applications and call _copyin()/_copyout()
! 70: # for user mode applications.
! 71: # When installing the 060SP, the _copyin()/_copyout() equivalents for a
! 72: # given operating system should be substituted.
! 73: #
! 74: # The addresses within the 060SP are guaranteed to be on the stack.
! 75: # The result is that Unix processes are allowed to sleep as a consequence
! 76: # of a page fault during a _copyout.
! 77: #
! 78:
! 79: #
! 80: # _060_dmem_write():
! 81: #
! 82: # Writes to data memory while in supervisor mode.
! 83: #
! 84: # INPUTS:
! 85: # a0 - supervisor source address
! 86: # a1 - user destination address
! 87: # d0 - number of bytes to write
! 88: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 89: # OUTPUTS:
! 90: # d1 - 0 = success, !0 = failure
! 91: #
! 92: global _060_dmem_write
! 93: _060_dmem_write:
! 94: btst &0x5,0x4(%a6) # check for supervisor state
! 95: beq.b user_write
! 96: super_write:
! 97: mov.b (%a0)+,(%a1)+ # copy 1 byte
! 98: subq.l &0x1,%d0 # decr byte counter
! 99: bne.b super_write # quit if ctr = 0
! 100: clr.l %d1 # return success
! 101: rts
! 102: user_write:
! 103: mov.l %d0,-(%sp) # pass: counter
! 104: mov.l %a1,-(%sp) # pass: user dst
! 105: mov.l %a0,-(%sp) # pass: supervisor src
! 106: bsr.l _copyout # write byte to user mem
! 107: mov.l %d0,%d1 # return success
! 108: add.l &0xc, %sp # clear 3 lw params
! 109: rts
! 110:
! 111: #
! 112: # _060_imem_read(), _060_dmem_read():
! 113: #
! 114: # Reads from data/instruction memory while in supervisor mode.
! 115: #
! 116: # INPUTS:
! 117: # a0 - user source address
! 118: # a1 - supervisor destination address
! 119: # d0 - number of bytes to read
! 120: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 121: # OUTPUTS:
! 122: # d1 - 0 = success, !0 = failure
! 123: #
! 124: global _060_imem_read
! 125: global _060_dmem_read
! 126: _060_imem_read:
! 127: _060_dmem_read:
! 128: btst &0x5,0x4(%a6) # check for supervisor state
! 129: beq.b user_read
! 130: super_read:
! 131: mov.b (%a0)+,(%a1)+ # copy 1 byte
! 132: subq.l &0x1,%d0 # decr byte counter
! 133: bne.b super_read # quit if ctr = 0
! 134: clr.l %d1 # return success
! 135: rts
! 136: user_read:
! 137: mov.l %d0,-(%sp) # pass: counter
! 138: mov.l %a1,-(%sp) # pass: super dst
! 139: mov.l %a0,-(%sp) # pass: user src
! 140: bsr.l _copyin # read byte from user mem
! 141: mov.l %d0,%d1 # return success
! 142: add.l &0xc,%sp # clear 3 lw params
! 143: rts
! 144:
! 145: #
! 146: # _060_dmem_read_byte():
! 147: #
! 148: # Read a data byte from user memory.
! 149: #
! 150: # INPUTS:
! 151: # a0 - user source address
! 152: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 153: # OUTPUTS:
! 154: # d0 - data byte in d0
! 155: # d1 - 0 = success, !0 = failure
! 156: #
! 157: global _060_dmem_read_byte
! 158: _060_dmem_read_byte:
! 159: btst &0x5,0x4(%a6) # check for supervisor state
! 160: bne.b dmrbs # supervisor
! 161: dmrbu: clr.l -(%sp) # clear space on stack for result
! 162: mov.l &0x1,-(%sp) # pass: # bytes to copy
! 163: pea 0x7(%sp) # pass: dst addr (stack)
! 164: mov.l %a0,-(%sp) # pass: src addr (user mem)
! 165: bsr.l _copyin # "copy in" the data
! 166: mov.l %d0,%d1 # return success
! 167: add.l &0xc,%sp # delete params
! 168: mov.l (%sp)+,%d0 # put answer in d0
! 169: rts
! 170: dmrbs: clr.l %d0 # clear whole longword
! 171: mov.b (%a0),%d0 # fetch super byte
! 172: clr.l %d1 # return success
! 173: rts
! 174:
! 175: #
! 176: # _060_dmem_read_word():
! 177: #
! 178: # Read a data word from user memory.
! 179: #
! 180: # INPUTS:
! 181: # a0 - user source address
! 182: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 183: # OUTPUTS:
! 184: # d0 - data word in d0
! 185: # d1 - 0 = success, !0 = failure
! 186: #
! 187: global _060_dmem_read_word
! 188: _060_dmem_read_word:
! 189: btst &0x5,0x4(%a6) # check for supervisor state
! 190: bne.b dmrws # supervisor
! 191: dmrwu: clr.l -(%sp) # clear space on stack for result
! 192: mov.l &0x2,-(%sp) # pass: # bytes to copy
! 193: pea 0x6(%sp) # pass: dst addr (stack)
! 194: mov.l %a0,-(%sp) # pass: src addr (user mem)
! 195: bsr.l _copyin # "copy in" the data
! 196: mov.l %d0,%d1 # return success
! 197: add.l &0xc,%sp # delete params
! 198: mov.l (%sp)+,%d0 # put answer in d0
! 199: rts
! 200: dmrws: clr.l %d0 # clear whole longword
! 201: mov.w (%a0), %d0 # fetch super word
! 202: clr.l %d1 # return success
! 203: rts
! 204:
! 205: #
! 206: # _060_dmem_read_long():
! 207: #
! 208:
! 209: #
! 210: # INPUTS:
! 211: # a0 - user source address
! 212: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 213: # OUTPUTS:
! 214: # d0 - data longword in d0
! 215: # d1 - 0 = success, !0 = failure
! 216: #
! 217: global _060_dmem_read_long
! 218: _060_dmem_read_long:
! 219: btst &0x5,0x4(%a6) # check for supervisor state
! 220: bne.b dmrls # supervisor
! 221: dmrlu: subq.l &0x4,%sp # clear space on stack for result
! 222: mov.l &0x4,-(%sp) # pass: # bytes to copy
! 223: pea 0x4(%sp) # pass: dst addr (stack)
! 224: mov.l %a0,-(%sp) # pass: src addr (user mem)
! 225: bsr.l _copyin # "copy in" the data
! 226: mov.l %d0,%d1 # return success
! 227: add.l &0xc,%sp # delete params
! 228: mov.l (%sp)+,%d0 # put answer in d0
! 229: rts
! 230: dmrls: mov.l (%a0),%d0 # fetch super longword
! 231: clr.l %d1 # return success
! 232: rts
! 233:
! 234: #
! 235: # _060_dmem_write_byte():
! 236: #
! 237: # Write a data byte to user memory.
! 238: #
! 239: # INPUTS:
! 240: # a0 - user destination address
! 241: # d0 - data byte in d0
! 242: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 243: # OUTPUTS:
! 244: # d1 - 0 = success, !0 = failure
! 245: #
! 246: global _060_dmem_write_byte
! 247: _060_dmem_write_byte:
! 248: btst &0x5,0x4(%a6) # check for supervisor state
! 249: bne.b dmwbs # supervisor
! 250: dmwbu: mov.l %d0,-(%sp) # put src on stack
! 251: mov.l &0x1,-(%sp) # pass: # bytes to copy
! 252: mov.l %a0,-(%sp) # pass: dst addr (user mem)
! 253: pea 0xb(%sp) # pass: src addr (stack)
! 254: bsr.l _copyout # "copy out" the data
! 255: mov.l %d0,%d1 # return success
! 256: add.l &0x10,%sp # delete params + src
! 257: rts
! 258: dmwbs: mov.b %d0,(%a0) # store super byte
! 259: clr.l %d1 # return success
! 260: rts
! 261:
! 262: #
! 263: # _060_dmem_write_word():
! 264: #
! 265: # Write a data word to user memory.
! 266: #
! 267: # INPUTS:
! 268: # a0 - user destination address
! 269: # d0 - data word in d0
! 270: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 271: # OUTPUTS:
! 272: # d1 - 0 = success, !0 = failure
! 273: #
! 274: global _060_dmem_write_word
! 275: _060_dmem_write_word:
! 276: btst &0x5,0x4(%a6) # check for supervisor state
! 277: bne.b dmwws # supervisor
! 278: dmwwu: mov.l %d0,-(%sp) # put src on stack
! 279: mov.l &0x2,-(%sp) # pass: # bytes to copy
! 280: mov.l %a0,-(%sp) # pass: dst addr (user mem)
! 281: pea 0xa(%sp) # pass: src addr (stack)
! 282: bsr.l _copyout # "copy out" the data
! 283: mov.l %d0,%d1 # return success
! 284: add.l &0x10,%sp # delete params + src
! 285: rts
! 286: dmwws: mov.w %d0,(%a0) # store super word
! 287: clr.l %d1 # return success
! 288: rts
! 289:
! 290: #
! 291: # _060_dmem_write_long():
! 292: #
! 293: # Write a data longword to user memory.
! 294: #
! 295: # INPUTS:
! 296: # a0 - user destination address
! 297: # d0 - data longword in d0
! 298: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 299: # OUTPUTS:
! 300: # d1 - 0 = success, !0 = failure
! 301: #
! 302: global _060_dmem_write_long
! 303: _060_dmem_write_long:
! 304: btst &0x5,0x4(%a6) # check for supervisor state
! 305: bne.b dmwls # supervisor
! 306: dmwlu: mov.l %d0,-(%sp) # put src on stack
! 307: mov.l &0x4,-(%sp) # pass: # bytes to copy
! 308: mov.l %a0,-(%sp) # pass: dst addr (user mem)
! 309: pea 0x8(%sp) # pass: src addr (stack)
! 310: bsr.l _copyout # "copy out" the data
! 311: mov.l %d0,%d1 # return success
! 312: add.l &0x10,%sp # delete params + src
! 313: rts
! 314: dmwls: mov.l %d0,(%a0) # store super longword
! 315: clr.l %d1 # return success
! 316: rts
! 317:
! 318: #
! 319: # _060_imem_read_word():
! 320: #
! 321: # Read an instruction word from user memory.
! 322: #
! 323: # INPUTS:
! 324: # a0 - user source address
! 325: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 326: # OUTPUTS:
! 327: # d0 - instruction word in d0
! 328: # d1 - 0 = success, !0 = failure
! 329: #
! 330: global _060_imem_read_word
! 331: _060_imem_read_word:
! 332: btst &0x5,0x4(%a6) # check for supervisor state
! 333: bne.b imrws # supervisor
! 334: imrwu: clr.l -(%sp) # clear space on stack for result
! 335: mov.l &0x2,-(%sp) # pass: # bytes to copy
! 336: pea 0x6(%sp) # pass: dst addr (stack)
! 337: mov.l %a0,-(%sp) # pass: src addr (user mem)
! 338: bsr.l _copyin # "copy in" the data
! 339: mov.l %d0,%d1 # return success
! 340: add.l &0xc,%sp # delete params
! 341: mov.l (%sp)+,%d0 # put answer in d0
! 342: rts
! 343: imrws: mov.w (%a0),%d0 # fetch super word
! 344: clr.l %d1 # return success
! 345: rts
! 346:
! 347: #
! 348: # _060_imem_read_long():
! 349: #
! 350: # Read an instruction longword from user memory.
! 351: #
! 352: # INPUTS:
! 353: # a0 - user source address
! 354: # 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
! 355: # OUTPUTS:
! 356: # d0 - instruction longword in d0
! 357: # d1 - 0 = success, !0 = failure
! 358: #
! 359: global _060_imem_read_long
! 360: _060_imem_read_long:
! 361: btst &0x5,0x4(%a6) # check for supervisor state
! 362: bne.b imrls # supervisor
! 363: imrlu: subq.l &0x4,%sp # clear space on stack for result
! 364: mov.l &0x4,-(%sp) # pass: # bytes to copy
! 365: pea 0x4(%sp) # pass: dst addr (stack)
! 366: mov.l %a0,-(%sp) # pass: src addr (user mem)
! 367: bsr.l _copyin # "copy in" the data
! 368: mov.l %d0,%d1 # return success
! 369: add.l &0xc,%sp # delete params
! 370: mov.l (%sp)+,%d0 # put answer in d0
! 371: rts
! 372: imrls: mov.l (%a0),%d0 # fetch super longword
! 373: clr.l %d1 # return success
! 374: rts
! 375:
! 376: ################################################
! 377:
! 378: #
! 379: # Use these routines if your kernel doesn't have _copyout/_copyin equivalents.
! 380: # Assumes that D0/D1/A0/A1 are scratch registers. The _copyin/_copyout
! 381: # below assume that the SFC/DFC have been set previously.
! 382: #
! 383:
! 384: #
! 385: # int _copyout(supervisor_addr, user_addr, nbytes)
! 386: #
! 387: global _copyout
! 388: _copyout:
! 389: mov.l 4(%sp),%a0 # source
! 390: mov.l 8(%sp),%a1 # destination
! 391: mov.l 12(%sp),%d0 # count
! 392: moreout:
! 393: mov.b (%a0)+,%d1 # fetch supervisor byte
! 394: movs.b %d1,(%a1)+ # store user byte
! 395: subq.l &0x1,%d0 # are we through yet?
! 396: bne.w moreout # no; so, continue
! 397: rts
! 398:
! 399: #
! 400: # int _copyin(user_addr, supervisor_addr, nbytes)
! 401: #
! 402: global _copyin
! 403: _copyin:
! 404: mov.l 4(%sp),%a0 # source
! 405: mov.l 8(%sp),%a1 # destination
! 406: mov.l 12(%sp),%d0 # count
! 407: morein:
! 408: movs.b (%a0)+,%d1 # fetch user byte
! 409: mov.b %d1,(%a1)+ # write supervisor byte
! 410: subq.l &0x1,%d0 # are we through yet?
! 411: bne.w morein # no; so, continue
! 412: rts
! 413:
! 414: ############################################################################
! 415:
! 416: #
! 417: # _060_real_trace():
! 418: #
! 419: # This is the exit point for the 060FPSP when an instruction is being traced
! 420: # and there are no other higher priority exceptions pending for this instruction
! 421: # or they have already been processed.
! 422: #
! 423: # The sample code below simply executes an "rte".
! 424: #
! 425: global _060_real_trace
! 426: _060_real_trace:
! 427: rte
! 428:
! 429: #
! 430: # _060_real_access():
! 431: #
! 432: # This is the exit point for the 060FPSP when an access error exception
! 433: # is encountered. The routine below should point to the operating system
! 434: # handler for access error exceptions. The exception stack frame is an
! 435: # 8-word access error frame.
! 436: #
! 437: # The sample routine below simply executes an "rte" instruction which
! 438: # is most likely the incorrect thing to do and could put the system
! 439: # into an infinite loop.
! 440: #
! 441: global _060_real_access
! 442: _060_real_access:
! 443: rte
CVSweb