home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / acorn / tech / 63 < prev    next >
Encoding:
Text File  |  1992-08-19  |  6.3 KB  |  109 lines

  1. Newsgroups: comp.sys.acorn.tech
  2. Path: sparky!uunet!kithrup!hoptoad!decwrl!sdd.hp.com!caen!sol.ctr.columbia.edu!ira.uka.de!chx400!dxcern!dscomsa.desy.de!vxdesy.desy.de!burke
  3. From: burke@vxdesy.desy.de
  4. Subject: Modules
  5. Message-ID: <1992Aug19.200810.1@vxdesy.desy.de>
  6. Lines: 97
  7. Sender: news@dscomsf.desy.de (USENET News System)
  8. Nntp-Posting-Host: vxdsyc.desy.de
  9. Organization: (DESY, Hamburg, Germany)
  10. Date: Wed, 19 Aug 1992 20:08:10 GMT
  11.  
  12. Someone was asking for "additions" to the PRM; here are a few random comments
  13. and questions, mostly related to modules.
  14.  
  15.   When writing a module which claims vectors, make sure you claim them again on
  16. Service_Reset, otherwise the module will stop working. Worse, if you have
  17. properly error-trapped finalisation code, if you try to RMReInit/RMKill it
  18. you'll get an error from trying to release unclaimed vectors, the module will
  19. get stuck (the workspace pointer says DEADDEAD!), and you can't get rid of it
  20. without a hard reset. This is rather frustrating during debugging; my solution
  21. is to keep changing the module name (you can't reload a module if an old one of
  22. the same name refuses to die). I've sometimes ended up with several versions of
  23. the same module, all DEADDEAD, before I've found the bug!
  24.  
  25.   Incidentally, don't forget that you can see the workspace pointer if you do
  26. *Modules, and then use *Memory to look at it. If you have a scratch area in the
  27. workspace you can write debugging information into it, and usually figure out
  28. what went wrong. A bit crude, but I don't know of any interactive debuggers for
  29. interrupt code!
  30.  
  31.   Module application code (entered from the start entry) runs in user mode,
  32. unlike the rest of the module code which is either in SVC or IRQ mode. This has
  33. a very important consequence, which should be written in six-foot-high letters
  34. of fire: *THERE* *IS* *NO* *STACK* (bangs head against nearest wall :-). If you
  35. want a stack you have to point R13 somewhere useful yourself.
  36.  
  37.   I have the following situation: the module workspace contains pointers to
  38. other blocks allocated by OS_Module Claim. Question: what happens on RMTidy?
  39. Answer: apparently, if you do nothing it's all OK (presumably RMA blocks which
  40. aren't module workspace don't get moved). Is this guaranteed to be safe? What
  41. else could you do, apart from refusing to be tidied?
  42.  
  43.   Another one from experience: if you have wimp code that starts up on
  44. Service_WimpStart, you have to be very careful if you do a Wimp_CloseDown
  45. without calling Wimp_Poll, as you tend to get stuck in an infinite loop (the
  46. Desktop module keeps trying to re-start you). Either make sure you always call
  47. Wimp_Poll at least once, or keep a flag that you've started and shut down
  48. again.
  49.  
  50.   It appears that the "command tail" pointer passed to OS_Module Enter must
  51. be valid, even if your code makes no use of it, as something in the OS seems
  52. to dereference it (not sure why). If you're unlucky this results in an address
  53. exception.
  54.  
  55.   I think that all the "command tail" pointers passed to your code point to the
  56. first non-space character of the tail, or to a control character if there is no
  57. tail. This isn't made entirely clear, however. I'm also not clear what is
  58. passed as the command tail if you RMRun a module; does the same pointer
  59. go to both the initialisation and the start code? The description of the start
  60. entry says that it points to the environment string including the file name.
  61. Is this really true? It presumably can't be if you start with OS_Module Enter,
  62. which is the normal case, and I suspect it isn't for RMRun either.
  63.  
  64.   The PRM seems a bit inconsistent on the subject of interrupts in SWIs. In the
  65. bit near the beginning on SWIs it says that although interrupts (IRQ) are
  66. disabled on entering the SWI handler, the IRQ mode is immediately restored to
  67. what it was when the SWI was called. This appears to be true (the code is right
  68. at the beginning of the SWI handler). However, in the documentation on
  69. providing SWIs in the module section (and nearly all SWIs are provided by
  70. modules, after all) it says that the code is entered with IRQs disabled, but
  71. you should enable them again if your code takes longer than [20 us?]. Is this
  72. true? Why bother to enable IRQs and then disable them again? (and then maybe
  73. enable them again). The "interrupts" bit of all the SWI documentation is a bit
  74. odd; why should it say "interrupt status preserved" (which must always be
  75. true), why does it always say "fast interrupts enabled" (I bet no SWI routines
  76. explicitly enable FIQs), and is there any meaning to the "re-entrancy" state if
  77. IRQs are disabled? For that matter, why bother to say that the processor is in
  78. SVC mode?
  79.  
  80.   While on the subject of SWIs, is anyone keeping a list of SWI chunks used by
  81. PD software like the filetypes list? Are Acorn allocating chunks for PD, or
  82. is it still ISVs only?
  83.  
  84.   Now to the thorny subject of errors. Although there are a few places where
  85. error codes are given (at the end of the wimp section, for example), there are
  86. no coherent lists, and no guidance on choosing error numbers for your own code.
  87. The documentation for SWIs also generally doesn't tell you if they can generate
  88. errors, and if so, under what circumstances. The OS_Module documentation is a
  89. partial exception to this, but it still doesn't tell you what the error numbers
  90. are. Also, are registers preserved after errors? R0 obviously can't be, but are
  91. other registers which are normally preserved still intact after an error?
  92.  
  93.   Another question is the extent to which SWIs should be error-trapped - are
  94. they expected to validate their parameters, or just take them on faith? The
  95. fact the I get address exceptions from OS_Module Enter, described above,
  96. suggests the latter. On the other hand, if you try to OS_Release an unclaimed
  97. vector you do get an error, whereas you might think it would just do nothing
  98. and return silently. Either way, it would be nice if it were *documented*!
  99.  
  100.   That's all I can think of for now. I wonder if the RISC OS3 PRMs are any
  101. better ...
  102.  
  103. e----><----p | Stephen Burke           | Internet: burke@vxdesy.desy.de
  104.  H   H   1   | Gruppe FH1T (Liverpool) | DECnet:   vxdesy::burke (13313::burke)
  105.  H   H  11   | DESY, Notkestrasse 85   | BITNET:   BURKE@DESYVAX or SB2@UKACRL
  106.  HHHHH   1   | 2000 Hamburg 52         | JANET:    sb2@uk.ac.rl.ib
  107.  H   H   1   | Germany                 | Phone:    + 49 40 8998 2282
  108.  H   H 11111 | HERA, the world's largest electron microscope!
  109.