os.S 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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. #include <linux/linkage.h>
  35. |################################
  36. | EXAMPLE CALL-OUTS #
  37. | #
  38. | _060_dmem_write() #
  39. | _060_dmem_read() #
  40. | _060_imem_read() #
  41. | _060_dmem_read_byte() #
  42. | _060_dmem_read_word() #
  43. | _060_dmem_read_long() #
  44. | _060_imem_read_word() #
  45. | _060_imem_read_long() #
  46. | _060_dmem_write_byte() #
  47. | _060_dmem_write_word() #
  48. | _060_dmem_write_long() #
  49. | #
  50. | _060_real_trace() #
  51. | _060_real_access() #
  52. |################################
  53. |
  54. | Each IO routine checks to see if the memory write/read is to/from user
  55. | or supervisor application space. The examples below use simple "move"
  56. | instructions for supervisor mode applications and call _copyin()/_copyout()
  57. | for user mode applications.
  58. | When installing the 060SP, the _copyin()/_copyout() equivalents for a
  59. | given operating system should be substituted.
  60. |
  61. | The addresses within the 060SP are guaranteed to be on the stack.
  62. | The result is that Unix processes are allowed to sleep as a consequence
  63. | of a page fault during a _copyout.
  64. |
  65. | Linux/68k: The _060_[id]mem_{read,write}_{byte,word,long} functions
  66. | (i.e. all the known length <= 4) are implemented by single moves
  67. | statements instead of (more expensive) copy{in,out} calls, if
  68. | working in user space
  69. |
  70. | _060_dmem_write():
  71. |
  72. | Writes to data memory while in supervisor mode.
  73. |
  74. | INPUTS:
  75. | a0 - supervisor source address
  76. | a1 - user destination address
  77. | d0 - number of bytes to write
  78. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  79. | OUTPUTS:
  80. | d1 - 0 = success, !0 = failure
  81. |
  82. .global _060_dmem_write
  83. _060_dmem_write:
  84. subq.l #1,%d0
  85. btst #0x5,0x4(%a6) | check for supervisor state
  86. beqs user_write
  87. super_write:
  88. move.b (%a0)+,(%a1)+ | copy 1 byte
  89. dbra %d0,super_write | quit if --ctr < 0
  90. clr.l %d1 | return success
  91. rts
  92. user_write:
  93. move.b (%a0)+,%d1 | copy 1 byte
  94. copyoutae:
  95. movs.b %d1,(%a1)+
  96. dbra %d0,user_write | quit if --ctr < 0
  97. clr.l %d1 | return success
  98. rts
  99. |
  100. | _060_imem_read(), _060_dmem_read():
  101. |
  102. | Reads from data/instruction memory while in supervisor mode.
  103. |
  104. | INPUTS:
  105. | a0 - user source address
  106. | a1 - supervisor destination address
  107. | d0 - number of bytes to read
  108. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  109. | OUTPUTS:
  110. | d1 - 0 = success, !0 = failure
  111. |
  112. .global _060_imem_read
  113. .global _060_dmem_read
  114. _060_imem_read:
  115. _060_dmem_read:
  116. subq.l #1,%d0
  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. dbra %d0,super_read | quit if --ctr < 0
  122. clr.l %d1 | return success
  123. rts
  124. user_read:
  125. copyinae:
  126. movs.b (%a0)+,%d1
  127. move.b %d1,(%a1)+ | copy 1 byte
  128. dbra %d0,user_read | quit if --ctr < 0
  129. clr.l %d1 | return success
  130. rts
  131. |
  132. | _060_dmem_read_byte():
  133. |
  134. | Read a data byte from user memory.
  135. |
  136. | INPUTS:
  137. | a0 - user source address
  138. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  139. | OUTPUTS:
  140. | d0 - data byte in d0
  141. | d1 - 0 = success, !0 = failure
  142. |
  143. .global _060_dmem_read_byte
  144. _060_dmem_read_byte:
  145. clr.l %d0 | clear whole longword
  146. clr.l %d1 | assume success
  147. btst #0x5,0x4(%a6) | check for supervisor state
  148. bnes dmrbs | supervisor
  149. dmrbuae:movs.b (%a0),%d0 | fetch user byte
  150. rts
  151. dmrbs: move.b (%a0),%d0 | fetch super byte
  152. rts
  153. |
  154. | _060_dmem_read_word():
  155. |
  156. | Read a data word from user memory.
  157. |
  158. | INPUTS:
  159. | a0 - user source address
  160. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  161. | OUTPUTS:
  162. | d0 - data word in d0
  163. | d1 - 0 = success, !0 = failure
  164. |
  165. | _060_imem_read_word():
  166. |
  167. | Read an instruction 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 - instruction word in d0
  174. | d1 - 0 = success, !0 = failure
  175. |
  176. .global _060_dmem_read_word
  177. .global _060_imem_read_word
  178. _060_dmem_read_word:
  179. _060_imem_read_word:
  180. clr.l %d1 | assume success
  181. clr.l %d0 | clear whole longword
  182. btst #0x5,0x4(%a6) | check for supervisor state
  183. bnes dmrws | supervisor
  184. dmrwuae:movs.w (%a0), %d0 | fetch user word
  185. rts
  186. dmrws: move.w (%a0), %d0 | fetch super word
  187. rts
  188. |
  189. | _060_dmem_read_long():
  190. |
  191. |
  192. | INPUTS:
  193. | a0 - user source address
  194. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  195. | OUTPUTS:
  196. | d0 - data longword in d0
  197. | d1 - 0 = success, !0 = failure
  198. |
  199. | _060_imem_read_long():
  200. |
  201. | Read an instruction longword from user memory.
  202. |
  203. | INPUTS:
  204. | a0 - user source address
  205. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  206. | OUTPUTS:
  207. | d0 - instruction longword in d0
  208. | d1 - 0 = success, !0 = failure
  209. |
  210. .global _060_dmem_read_long
  211. .global _060_imem_read_long
  212. _060_dmem_read_long:
  213. _060_imem_read_long:
  214. clr.l %d1 | assume success
  215. btst #0x5,0x4(%a6) | check for supervisor state
  216. bnes dmrls | supervisor
  217. dmrluae:movs.l (%a0),%d0 | fetch user longword
  218. rts
  219. dmrls: move.l (%a0),%d0 | fetch super longword
  220. rts
  221. |
  222. | _060_dmem_write_byte():
  223. |
  224. | Write a data byte to user memory.
  225. |
  226. | INPUTS:
  227. | a0 - user destination address
  228. | d0 - data byte in d0
  229. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  230. | OUTPUTS:
  231. | d1 - 0 = success, !0 = failure
  232. |
  233. .global _060_dmem_write_byte
  234. _060_dmem_write_byte:
  235. clr.l %d1 | assume success
  236. btst #0x5,0x4(%a6) | check for supervisor state
  237. bnes dmwbs | supervisor
  238. dmwbuae:movs.b %d0,(%a0) | store user byte
  239. rts
  240. dmwbs: move.b %d0,(%a0) | store super byte
  241. rts
  242. |
  243. | _060_dmem_write_word():
  244. |
  245. | Write a data word to user memory.
  246. |
  247. | INPUTS:
  248. | a0 - user destination address
  249. | d0 - data word in d0
  250. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  251. | OUTPUTS:
  252. | d1 - 0 = success, !0 = failure
  253. |
  254. .global _060_dmem_write_word
  255. _060_dmem_write_word:
  256. clr.l %d1 | assume success
  257. btst #0x5,0x4(%a6) | check for supervisor state
  258. bnes dmwws | supervisor
  259. dmwwu:
  260. dmwwuae:movs.w %d0,(%a0) | store user word
  261. bras dmwwr
  262. dmwws: move.w %d0,(%a0) | store super word
  263. dmwwr: clr.l %d1 | return success
  264. rts
  265. |
  266. | _060_dmem_write_long():
  267. |
  268. | Write a data longword to user memory.
  269. |
  270. | INPUTS:
  271. | a0 - user destination address
  272. | d0 - data longword in d0
  273. | 0x4(%a6),bit5 - 1 = supervisor mode, 0 = user mode
  274. | OUTPUTS:
  275. | d1 - 0 = success, !0 = failure
  276. |
  277. .global _060_dmem_write_long
  278. _060_dmem_write_long:
  279. clr.l %d1 | assume success
  280. btst #0x5,0x4(%a6) | check for supervisor state
  281. bnes dmwls | supervisor
  282. dmwluae:movs.l %d0,(%a0) | store user longword
  283. rts
  284. dmwls: move.l %d0,(%a0) | store super longword
  285. rts
  286. #if 0
  287. |###############################################
  288. |
  289. | Use these routines if your kernel doesn't have _copyout/_copyin equivalents.
  290. | Assumes that D0/D1/A0/A1 are scratch registers. The _copyin/_copyout
  291. | below assume that the SFC/DFC have been set previously.
  292. |
  293. | Linux/68k: These are basically non-inlined versions of
  294. | memcpy_{to,from}fs, but without long-transfer optimization
  295. | Note: Assumed that SFC/DFC are pointing correctly to user data
  296. | space... Should be right, or are there any exceptions?
  297. |
  298. | int _copyout(supervisor_addr, user_addr, nbytes)
  299. |
  300. .global _copyout
  301. _copyout:
  302. move.l 4(%sp),%a0 | source
  303. move.l 8(%sp),%a1 | destination
  304. move.l 12(%sp),%d0 | count
  305. subq.l #1,%d0
  306. moreout:
  307. move.b (%a0)+,%d1 | fetch supervisor byte
  308. copyoutae:
  309. movs.b %d1,(%a1)+ | store user byte
  310. dbra %d0,moreout | are we through yet?
  311. moveq #0,%d0 | return success
  312. rts
  313. |
  314. | int _copyin(user_addr, supervisor_addr, nbytes)
  315. |
  316. .global _copyin
  317. _copyin:
  318. move.l 4(%sp),%a0 | source
  319. move.l 8(%sp),%a1 | destination
  320. move.l 12(%sp),%d0 | count
  321. subq.l #1,%d0
  322. morein:
  323. copyinae:
  324. movs.b (%a0)+,%d1 | fetch user byte
  325. move.b %d1,(%a1)+ | write supervisor byte
  326. dbra %d0,morein | are we through yet?
  327. moveq #0,%d0 | return success
  328. rts
  329. #endif
  330. |###########################################################################
  331. |
  332. | _060_real_trace():
  333. |
  334. | This is the exit point for the 060FPSP when an instruction is being traced
  335. | and there are no other higher priority exceptions pending for this instruction
  336. | or they have already been processed.
  337. |
  338. | The sample code below simply executes an "rte".
  339. |
  340. .global _060_real_trace
  341. _060_real_trace:
  342. bral trap
  343. |
  344. | _060_real_access():
  345. |
  346. | This is the exit point for the 060FPSP when an access error exception
  347. | is encountered. The routine below should point to the operating system
  348. | handler for access error exceptions. The exception stack frame is an
  349. | 8-word access error frame.
  350. |
  351. | The sample routine below simply executes an "rte" instruction which
  352. | is most likely the incorrect thing to do and could put the system
  353. | into an infinite loop.
  354. |
  355. .global _060_real_access
  356. _060_real_access:
  357. bral buserr
  358. | Execption handling for movs access to illegal memory
  359. .section .fixup,#alloc,#execinstr
  360. .even
  361. 1: moveq #-1,%d1
  362. rts
  363. .section __ex_table,#alloc
  364. .align 4
  365. .long dmrbuae,1b
  366. .long dmrwuae,1b
  367. .long dmrluae,1b
  368. .long dmwbuae,1b
  369. .long dmwwuae,1b
  370. .long dmwluae,1b
  371. .long copyoutae,1b
  372. .long copyinae,1b
  373. .text