insert_kernel_rom_calls.hss 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. [Main]
  2. Title=__ld_insert_kernel_rom_calls
  3. See Also=insert_mlink_rom_calls: __ld_insert_mlink_rom_calls, insert_compressed_rom_calls: __ld_insert_compressed_rom_calls
  4. [Top]
  5. __ld_insert_kernel_rom_calls can be used to handle
  6. <A HREF="$$LINK(symbols_rom_call)">ROM calls</A>. It inserts references to
  7. ROM calls in the format used by kernels:
  8. <UL>
  9. <LI>If the program uses at least one ROM call...
  10. <UL>
  11. <LI><B>2 bytes:</B> the number of different ROM calls minus 1</LI>
  12. <LI>For each ROM call...
  13. <UL>
  14. <LI><B>2 bytes:</B> <I>index</I> of the ROM call</LI>
  15. <LI>Relocation table for this ROM call:
  16. <UL>
  17. <LI>For each reference...
  18. <UL>
  19. <LI><B>2 bytes:</B> <I>location</I> (may not be 0)</LI>
  20. </UL></LI>
  21. <LI><B>2 bytes:</B> 0</LI>
  22. </UL></LI>
  23. </UL></LI>
  24. </UL></LI>
  25. </UL>
  26. If a program uses this insertion, it must process it as follows:
  27. <UL>
  28. <LI>For each ROM call...
  29. <UL>
  30. <LI>For each relocation entry...
  31. <UL>
  32. <LI>Get the starting address of the program (via
  33. <A HREF="$$LINK(symbols_ld_entry_point)">__ld_entry_point</A>);</LI>
  34. <LI>Add the <I>location</I> value;</LI>
  35. <LI>Modify the 4-byte value (<I>offset</I>) at the resulting address:
  36. <UL>
  37. <LI>Get the address of the ROM function/variable indexed by
  38. <I>index</I>;</LI>
  39. <LI>Add the value of <I>offset</I>;</LI>
  40. <LI>Write the resulting address to the 4-byte space covered by
  41. <I>offset</I>.</LI>
  42. </UL></LI>
  43. </UL></LI>
  44. </UL></LI>
  45. </UL>
  46. Before program termination, this process has to be reverted, so that it can
  47. be repeated the next time the program starts. Simply deactivating the
  48. relocation code would prevent programs from being transferred between
  49. devices.