hw_version.s 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. | Hardware version detection, adapted from gray.s
  2. | Copyright (C) 2002 Thomas Nussbaumer.
  3. | Copyright (C) 2003 Kevin Kofler.
  4. | See License.txt for licensing conditions.
  5. .xdef __get_hw_version
  6. __get_hw_version:
  7. |--------------------------------------------------------------------------
  8. | get the HW parm block using the algorithm suggested by Julien Muchembled
  9. |--------------------------------------------------------------------------
  10. move.l 0xc8:w,%d0
  11. andi.l #0xE00000,%d0 | get the ROM base
  12. movea.l %d0,%a0
  13. movea.l 260(%a0),%a1 | get pointer to the hardware param block
  14. adda.l #0x10000,%a0
  15. cmpa.l %a0,%a1 | check if the HW parameter block is near enough
  16. bcc.s L.is_hw1 | if it is too far, it is HW1
  17. cmpi.w #22,(%a1) | check if the parameter block contains HW ver
  18. bls.s L.is_hw1 | if it is too small, it is HW1
  19. |--------------------------------------------------------------------------
  20. | check for VTI (trick suggested by Julien Muchembled)
  21. |--------------------------------------------------------------------------
  22. trap #12 | enter supervisor mode. returns old (%sr) in %d0.w
  23. move.w #0x3000,%sr | set a non-existing flag in %sr (but keep s-flag)
  24. move.w %sr,%d1 | get %sr content and check for non-existing flag
  25. move.w %d0,%sr | restore old %sr content
  26. btst.l #12,%d1 | this non-existing flag can only be set on the VTI
  27. beq.s L.not_vti | flag not set -> no VTI
  28. |--------------------------------------------------------------------------
  29. | VTI detected -> treat as HW1
  30. |--------------------------------------------------------------------------
  31. | Fall through...
  32. L.is_hw1:
  33. |--------------------------------------------------------------------------
  34. | HW1 detected
  35. |--------------------------------------------------------------------------
  36. moveq.l #1,%d0 | set %d0 to 1 (HW1)
  37. rts | return 1
  38. L.not_vti:
  39. |--------------------------------------------------------------------------
  40. | Real calculator detected, so read the HW version from the HW parm block
  41. |--------------------------------------------------------------------------
  42. move.l 22(%a1),%d0 | get the hardware version
  43. rts | return it