root/arch/m68k/ifpsp060/os.S

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

/* [previous][next][first][last][top][bottom][index][help] */