home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / misc / tornado / tndemo2 / _Kernel next >
Text File  |  1996-06-03  |  33KB  |  762 lines

  1. Notes:
  2. -=-=-=
  3. Fix TTiming to stop slowing down my machine!
  4. Add Tornado_Callback
  5. Add all the Tornado filing system SWIs
  6.    - do specs for them
  7. Finish that window renderer!
  8. Add Tornado_CoordGraphics which plots all coord graphics
  9. Add Tornado_Text which plots all text
  10. Add Tornado_Bitmap which plots all bitmaps
  11. Add specs for multithreading multitasking in assembler
  12.    - write it!
  13.    - think about them for C and Basic [difficult!]
  14. Revise these outdated docs!
  15.  
  16.  
  17. Tornado kernel
  18. -=-=-=-=-=-=-=
  19.  
  20. This is cursory documentation covering the tornado kernel v0.10 (29-12-1995).
  21.  
  22. The Tornado kernel extends the RISC-OS kernel by providing:
  23.  * Management of tornado code
  24.     - Its own service call handler
  25.     - Its own vector handler
  26.     - Function and procedure calls to interface with RISC-OS
  27.     - Tornado_Register
  28.     - Tornado_Function
  29.  * Extended memory and heap management facilites
  30.     - Tornado_Initheap
  31.     - Tornado_Getblk
  32.     - Tornado_Freeblk
  33.     - Tornado_Extblk
  34.     - Tornado_HeapInfo
  35.     - Tornado_ExtHeap
  36.     - Tornado_Getaddr
  37.     - Tornado_GarbageHeap
  38.  * Extended sprite (bitmap) facilities
  39.     - Tornado_SpriteOp (#001)
  40.  * Miscellaneous extensions
  41.     - Tornado_Hourglass (#002)
  42.  
  43.    ... and general control of TShell and TLib running under the kernel.
  44.  
  45. The tornado kernel is loaded in as a RISC-OS module, and during initiation
  46. claims workspace:
  47.  +00: reserved
  48.  +04: Tornado version * 100
  49.  +08: RISC-OS kernel version * 100
  50.  +12: handle of list of clients
  51.  +16: handle of function vector list
  52.  +32: wkspace for Tornado_Register
  53.  +36: wkspace for Tornado_Register
  54.  +128: 128 bytes of general wkspace
  55.  +256: start of tornado shared system heap
  56.  
  57. The only facilities at present contained within the kernel are the heap
  58. management SWIs. All other facilties are vectored out of the kernel into
  59. subsiduary modules which link themselves into tornado during initiation.
  60.  
  61. *Note* that tornado extension modules do NOT usually participate in RISC-OS
  62. operations unless it is through the tornado kernel. In other words, they do
  63. not provide their own SWIs, participate with RISC-OS service calls etc -
  64. however, they can, will and do use RISC-OS facilities as vectoring these
  65. through the tornado kernel (which would only pass them onto RISC-OS anyway)
  66. is resource-wasteful.
  67.  
  68. You will notice tornado has undergone quite a change since you previously
  69. heard from me last summer (1995). It has been hacked down into a much more
  70. modular form, made much more streamlined and flexible. I am not a great
  71. believer in monolithic operating systems, and tornado I felt was becoming a
  72. little monolithic in nature. Thus, I broke the hourglass handling routines
  73. etc into seperate modules which now register their presence with tornado when
  74. they load in.
  75.  
  76. These docs aren't hugely detailed. Below is simply a list of SWIs, data
  77. structures and various other bits and pieces currently defined.
  78.  
  79.  Niall Douglas.
  80.  5th January 1996.
  81.  
  82.  
  83.  
  84.  
  85.  
  86. The current format of tornado extended heaps:
  87.    +00:&70616548 = "Heap", like with OS_Heap    |
  88.    +04:Offset to free list            | Note this is the standard
  89.    +08:Offset to heap base            | OS_Heap header
  90.    +12:Offset to heap end            |
  91.    +16:&20 = the Heap+ identifier - also to OS_Heap indicates a block length
  92.    +20:offset within heap to the list of non-relocatable blocks
  93.       +0: length of list in bytes (beginning=0)
  94.       +4: offset within heap to an allocated block descriptor
  95.    +24:offset within heap to the list of relocatable blocks
  96.       +0: length of list in bytes (beginning=0)
  97.       +4: offset within heap to an allocated block descriptor
  98.           This is negative if block is locked
  99.    +28:flags
  100.       bit 0: this heap is auto-extending using Wimp_SlotSize
  101.       bit 1: this heap is auto-extending using OS_Module
  102.       bit 2: this heap is auto-extending using Tornado_Extblk
  103.       bit 30:this heap is auto-extending as the Tornado system heap
  104.       bit 31:disable garbage collection if bit 30 set (ie; is negative)
  105.    +32: base of heap+ heap containing this heap+ heap if bit 2 of +28 is set
  106.         MUST be physical address OR special address eg; 0,1,-1,-2,-3 etc
  107.    +36: block within above heap that holds this heap
  108.    +40: Reserved for future use
  109.  
  110. Also, the format of each allocated blk:
  111.  ___
  112. /    -36: Filetype of file
  113. |    -32: First block of file
  114. |    -28: Total length of file contained in these blocks (higher word)
  115. |    -24: Total length of file contained in these blocks (lower word)
  116. |    -20: reloc ptr of linked block before this one (=0 if first)
  117. |    -16: reloc ptr of linked block after this one (=0 if last)
  118. |    -12: normally nothing before this, but when the block is one of a
  119. |         linked list (denoted by bit 29 in the flags) then this word is the
  120. |         fragment length of the block (max len this block can be before it
  121. \___      spawns another block)
  122.  /|\
  123.   |
  124. **  Note this may be replaced with a far simple approach later  **
  125.  
  126.    -08: Flags
  127.         bit 30: clear=nonreloc, set=reloc
  128.         bit 29: set means this block is one of a linked list
  129.    -04: length of data (not including this header). Negative if the data is
  130.         on disc and not in memory.
  131.    +00: start of data if data is in memory, or end of block if data is on
  132.         disc. Blocks are stored in the format (for example)
  133.         "<Tornado$MemoryCache>.F.F.F.F.F.F.F.F" for block -1.
  134.  
  135.  
  136.  
  137.  
  138. Tornado_Register                    (SWI &C0000)
  139. On entry:
  140.    R0=flags
  141.       bits 0,1:
  142.             =0: register
  143.             =1: deregister
  144.             =2: enumerate extensions
  145.             =3: return info on a particular extension module
  146.  For R0 AND %11=0,1:
  147.    R1=addr of RISC-OS module title with instantiation descriptor
  148.    R2=addr of data block
  149.  For R0 AND %11=2:
  150.    R4=0 to start enumeration
  151.  For R0 AND %11=3:
  152.    R1=addr of RISC-OS module title with instantiation descriptor
  153. On exit:
  154.  For R0 AND %11=0,1:
  155.    All registers preserved
  156.  For R0 AND %11=2:
  157.    R1=RO module title
  158.    R2=addr of data block
  159.    R3=memory word
  160.    R4=new enumeration value, or -1 for end of list
  161.    Z will be set if no entry was returned
  162.  For R0 AND %11=3:
  163.    R2=addr of data block
  164.    R3=contents of memory word
  165.    All other registers preserved
  166. Interrupts: IRQ's enabled
  167. Processor mode: SVC
  168. Re-entrancy: None
  169. Use:
  170.    Used to register an extension module with the tornado kernel. The data
  171. block is of the following format:
  172.  +00: format of this list (currently =0)
  173.  +04: offset to tornado module name (48 char limit)
  174.       eg; "Tornado hourglass'"
  175.  +08: offset to version of module (8 char limit), date started, date last
  176.       updated (last two binary encoded)
  177.       eg; "1.00ß",xxx,xxx
  178.  +12: offset to credits list (OS_PrettyPrint used) (80 char limit)
  179.       and registered number of developer (=0 if not registered)
  180.       eg; "© 1996 N. Douglas",xxx
  181.  +16: version of tornado this module expects * 100
  182.  +20: version of RISC-OS this module written on * 100
  183.  +24: version of tornado above which this module probably won't work
  184.       correctly on (=0 if all versions okay)
  185.  +28: version of RISC-OS above which this module probably won't work
  186.       correctly on (=0 if all versions okay)
  187.  +32: flags:
  188.       bit 0: almost certainly will not work on tornado versions below that
  189.              specified
  190.       bit 1: almost certainly will not work on RISC-OS versions below that
  191.              specified
  192.       bit 2: almost certainly will not work on tornado versions above that
  193.              specified
  194.       bit 3: almost certainly will not work on RISC-OS versions above that
  195.              specified
  196.  +36: offset to initialisation code
  197.  +40: offset to finalisation code
  198.  +44: offset to service call code
  199.    
  200.    Binary encoded times are two words of the following format:
  201.    %VVVVRRRREEEEEEEESDDDDDDDDDDDDDDD (1st word)
  202.    %DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD (2nd word)
  203.    The D bits are the number of milliseconds since 12:00am January 1st year
  204.     0.
  205.    The S bit is the sign of the D bits - before or after 12:00am January 1st
  206.     year 0.
  207.    The E bits are an eight bit exponent number. The milliseconds from the D
  208.     bits are multiplied by 10 to the power of the exponent number.
  209.    The R bits are reserved for version number 0, undefined for other
  210.     versions.
  211.    The V bits are for version number of the format - current all zero
  212.       This format gives a theoretical range of + or - 2^47*10^255 which is
  213. around four and a half x 10^258 years, which is enough to get back to the
  214. start of the universe, and possibly the end of it, which was my intention.
  215.    
  216.    The initialise and finalise entries should be seperate from your module's
  217. initialise and finalise entries in that tornado may call your module through
  218. finalise then initialise to restart your module should it get into
  219. difficulties. Your module's RISC-OS initialise and finalise entries should
  220. merely register and deregister itself using this SWI.
  221.    Note that the initialise entry is supplied with only R13, the supervisor
  222. stack, and R14 which is the link back into tornado. Your routine may corrupt
  223. all registers except R13 and the current processor mode (SVC), and should
  224. return with a MOVS PC,R14 type construction, making sure to copy across the
  225. PSR.
  226.    Note also however that the contents of R12 on exit from your initialise
  227. routine have a special meaning - they are stored and retained by tornado for
  228. future passing to all your routines.
  229.    Obviously, standard RO error handling practices are in force here - and as
  230. with almost all tornado entries into your code, you can return an error by
  231. setting V and R0 as appropriate. However, all tornado does (currently) with
  232. this is to return the very same error back out of Tornado_Register, so make
  233. sure your RO initialise entry has error handling implemented for that.
  234.  
  235. Data struct of client list at +12:
  236.  +00: addr of RO name of module
  237.  +04: version of tornado it expects
  238.  +08: version of RISC-OS it was written for
  239.  +12: addr of the data block it passed us first day
  240.  +16: addr of its init code
  241.  +20: addr of its final code
  242.  +24: addr of its service code
  243.  +28: value to pass in R12
  244.  
  245.  Note that R12 on exit from the initialise entry will become R12 for the
  246. service or function entries.
  247.  
  248.  
  249.  
  250. Tornado_Function                    (SWI &C0001)
  251. On entry:
  252.    R0=flags
  253.     bit 0: clear to register, set to deregister (N/I yet)
  254.    R1=addr of RO module name
  255.    R2=addr of data blk
  256.    R3=ptr to list of call numbers and code entries
  257.    R4=R12 to call with
  258. On exit:
  259.    All registers preserved
  260. Interrupts: IRQ's enabled
  261. Processor mode: SVC
  262. Re-entrancy: Full
  263. Use:
  264.    Used to declare an extension module's intent to provide a service or SWI
  265. call. You may also replace existing calls using this call.
  266.    Simply pass a list made up of the following blocks, terminated with a
  267. null word:
  268.  +00:flags
  269.     bit 0: always set
  270.     bit 1: clear is register, set is deregister
  271.     bit 2: set means we want to intercept the existing provider
  272.     bit 15: set means we are a bugfix
  273.  +04:Call number this entry refers to
  274.  +08:Offset of code entry from module base
  275.  
  276.    If you are providing this call (bit 1 clear), then your code entry will be
  277. entered with all the registers that you would expect. If you are
  278. intercepting, then your code entry will be entered with all the registers
  279. intact but R14 will return to the original provider, and the link to return
  280. to tornado will be on the stack. This allows you to pre and post process the
  281. original providers code.
  282.    Note that you cannot count on your code entry to be accepted. You will
  283. never be told whether your code is used to provide the call or not, and you
  284. should *never* assume that it is (ie; have other function code rely on data
  285. shared with other function code). Tornado also may use your code to provide
  286. some calls but not others ie; some of your entries may be used, others may
  287. not.
  288.    Bit 15 allows you declare yourself to be a bugfix. This means that your
  289. code will be more likely to be installed.
  290.  
  291.  List struct:
  292.    +00: RO module name
  293.    +04: data blk
  294.    +08: flags
  295.    +12: call number
  296.    +16: address of code
  297.    +20: R12 to call with
  298.    +24 to +28: reserved
  299.  
  300.  
  301. Tornado_Initheap                    (SWI &)
  302. On entry:
  303.    R0=flags
  304.       bit 0: This heap is a Wimp postslot heap
  305.       bit 1: This heap is a heap within an OS_Module block in RMA
  306.       bit 2: This heap is a heap within a Heap+ block
  307.       bit 30: This heap being initialised is the proposed Tornado system heap
  308.    R1=ptr to proposed heap base
  309.    R2=ptr to addr of heap base if bit 2 set
  310.    R3=length of proposed heap (must be >1024 bytes)
  311.    R4=handle of block within heap pointed to by R1 if bit 2 set
  312. On exit:
  313.    R0=corrupted
  314.    R1=ptr to heap base
  315.    All registers preserved
  316. Interrupts: IRQ's enabled
  317. Processor mode: SVC
  318. Re-entrancy: Full
  319. Use:
  320.    Used to initialise a Tornado Heap+ type heap. This heap format is based on
  321. OS_Heap style heaps, and offers complete internal format compatibility with
  322. OS_Heap style heaps, and thus relies on the current structure of OS_Heap
  323. heaps. It will complain if OS_Heap uses a format it does not know about.
  324.    The area of memory you intend to initialise will be verified, and header
  325. and other information written into it. Note minimum size is 1024 bytes, and
  326. the base must begin on a word-aligned address. The length must be a multiple
  327. of 4 bytes.
  328.    Note that if bit 0 is set then the task's wimpslot is automatically
  329. extended by an appropriate amount and the heap set up at the previous
  330. environment end address which should be passed in R1 on entry. From now on,
  331. any extensions to the heap needed will be done automatically, extending the
  332. wimpslot as necessary. Bit 1 will extend it using OS_Module; bit 2 will
  333. extend it using Tornado_Extblk, which may cause a cascade extension down
  334. through blocks in heaps below the heap being extended.
  335.    Note also that the heap+ structure itself is relocatable - this means all
  336. heap+ heaps can also be stored in a Heap+ or otherwise relocatable block.
  337.  
  338. Tornado_Getblk                        (SWI &)
  339. On entry:
  340.    R0=flags
  341.       bit 0: this block is relocatable
  342.       bit 1: Don't return address of block in R2
  343.       bit 2: don't do a garbage collection after this call
  344.       bit 29:(internal) this is the subtask heap
  345.       bit 30:(internal) this is the system heap
  346.    R1=heap+ ptr, 0 if system heap, 1 if subtask heap
  347.       -1,-2 refers to task heaps (NOT IMPLEMENTED YET!)
  348.    R3=size of block wanted
  349.    Other registers not used as yet
  350. On exit:
  351.    R0=corrupted
  352.    R1=updated heap+ ptr if R1<>magic heap no on entry
  353.    R2=addr of block, otherwise preserved if bit 1 is set
  354.    R3=handle of block
  355.    All other registers preserved
  356. Interrupts: IRQ's enabled
  357. Processor mode: SVC
  358. Re-entrancy: Full
  359. Use:
  360.    Used to claim a block from a Heap+ heap. As in other tornado heap calls,
  361. R1 may either point to an actual heap, or may be a 'magic' heap number. These
  362. are currently defined as:
  363.   0: Tornado shared system heap (stored in RMA)
  364.   1: Tornado subtask shared heap (undefined location currently)
  365.  -1: Private heap of first tornado task
  366.  -2: Private heap of second tornado task
  367.  -3: etc
  368.    If you ask for a relocatable block (by setting bit 0), which is _strongly_
  369. recommended, then you will be given a handle which from hence you can use to
  370. reference the block by. It will always be a negative number, and any data
  371. contained within the block must be able to be relocated at arbitrary times.
  372. You will not know if/when/how/why the block has been moved. To get the
  373. _current_ address of the block, use Tornado_Getaddr. Read its entry for
  374. further details of use. You are guaranteed that your block will NOT move
  375. between calls concerning your heap to tornado, except for shared heaps which
  376. may be accessed by another party without your knowledge. Thus, you should
  377. take measures to prevent your block moving while you use it.
  378.    If you ask for a non-relocatable block, the handle will be equal to the
  379. start of the block. However, it is good programming practice to also call
  380. Tornado_Getaddr for this handle, just to be sure you are getting the address
  381. of the block (also makes sure if you change it later you won't have to change
  382. too much of your code).
  383.    Unless you specifically ask otherwise, an automatic garbage collection
  384. will be performed after this call, unless it has been disabled (only for
  385. system heap). Also, for your convenience the current position of the block is
  386. returned in R2.
  387.    Note that if you have specified auto-extending in Tornado_Initheap call,
  388. then this call will only return an error if the entire heap couldn't be
  389. extended, otherwise it's because the heap is full.
  390.    Note also that recursion is possible here: this heap being extended by
  391. this call may cause the heap it's in to extend which may cause the heap it's
  392. in to also extend. Failure of any one of these will return an error from this
  393. command. Also, this command thus may take a while having to garbage and
  394. extend multiple heaps.
  395.  
  396. Tornado_Freeblk                        (SWI &)
  397. On entry:
  398.    R0=flags
  399.       bit 2: don't do a garbage collection after this call
  400.       bit 29:(internal) this is the subtask heap
  401.       bit 30:(internal) this is the system heap
  402.    R1=heap+ ptr, or 'magic' heap no
  403.    R3=handle of block
  404. On exit:
  405.    R0=corrupted
  406.    R1=updated heap+ ptr if R1<>'magic' heap no
  407.    All other registers preserved
  408. Interrupts: IRQ's enabled
  409. Processor mode: SVC
  410. Re-entrancy: Full
  411. Use:
  412.    Used to free a claimed block.
  413.    Unless you specifically ask otherwise, an automatic garbage collection
  414. will be performed after this call, and if auto-extending is set, then the
  415. heap will be automatically shrunk if possible. This, as above, may lead to
  416. all heaps in the tree above to shrink as well. Thus, this command may take a
  417. while having to garbage and shrink multiple heaps.
  418.  
  419. Tornado_Extblk                        (SWI &)
  420. On entry:
  421.    R0=flags
  422.       bit 0: don't bother returning new size
  423.       bit 1: don't bother returning current address
  424.       bit 2: don't do a garbage collection after this call
  425.       bit 29:(internal) this is the subtask heap
  426.       bit 30:(internal) this is the system heap
  427.    R1=heap+ ptr, or 'magic' heap no
  428.    R2=signed change in bytes
  429.    R3=handle of block
  430. On exit:
  431.    R0=corrupted
  432.    R1=updated heap+ ptr if R1<>'magic' heap no
  433.    R2=current addr of block
  434.    R3=new handle of block
  435.    R4=new size of block
  436.    All other registers preserved
  437. Interrupts: IRQ's enabled
  438. Processor mode: SVC
  439. Re-entrancy: Full
  440. Use:
  441.    Used to change the size of a claimed block. Note that the new size of the
  442. block may be larger than you intended, as it is always rounded up to the
  443. nearest word. This is alright: just take care to redo any future resizing
  444. decisions (ie; if storing the size, don't store previous size changed by the
  445. requested size change, store the size returned by R2 instead). This will
  446. prevent bytes 'appearing' on the end of the block that you will never use.
  447.    The new handle for the block will be the same if the block was
  448. relocatable, but note it is good programming practice if you restore the
  449. handle anyway, in case you may later have to alter the relocatable nature of
  450. the data.
  451.    Unless you specifically ask otherwise, an automatic garbage collection
  452. will be performed after this call, and the repercussions are as for
  453. Tornado_Getblk and Tornado_Freeblk.
  454.  
  455. Tornado_ExtHeap                        (SWI &)
  456. On entry:
  457.    R0=flags
  458.       bit 29:(internal) this is the subtask heap
  459.       bit 30:(internal) this is the system heap
  460.    R1=heap+ ptr, 0 if system heap, 1 if subtask heap
  461.    R2=signed change in size
  462. On exit:
  463.    R2=new size
  464.    All other registers preserved
  465. Interrupts: IRQ's enabled
  466. Processor mode: SVC
  467. Re-entrancy: Full
  468. Use:
  469. Used to manually change the size of a Heap+ heap. Usually automated. Note
  470. this may cause auto-extending heaps above this to garbage and also change
  471. size.
  472. Related calls:
  473.    All tornado heap calls;
  474.  
  475. Tornado_Getaddr                        (SWI &)
  476. On entry:
  477.    R0=flags
  478.       bit 0: don't cache block
  479.       bit 1: preserve R4 on exit (ie; don't bother calculating it)
  480.       bit 29:(internal) this is the subtask heap
  481.       bit 30:(internal) this is the system heap
  482.    R1=heap+ ptr, 0 if system heap, 1 if subtask heap
  483.    R2=offset within block you wish to access (if block fragmented)
  484.    R3=handle of block
  485.    R4=number of bytes to be made contiguous (-1=full length)
  486. On exit:
  487.    R2=actual address of block (points to offset given by R2)
  488.    R3=reloc handle of block if bit 0 was set on entry; otherwise preserved
  489.    R4=number of bytes from R2 you can access before you must call this SWI
  490.       again (may be to end of block though)
  491.    All other registers preserved
  492. Interrupts: IRQ's enabled
  493. Processor mode: SVC
  494. Re-entrancy: Full
  495. Use:
  496. Used to determine the actual address of a claimed block. If the handle passed
  497. is non-negative, then the same handle is currently returned in R2.
  498.    The offset contained within R2 is the patch of data within the block you
  499. wish to access. This should be given even if the block isn't fragmented, as
  500. the user may have specified that a cap be placed on requests.
  501.    You can work out what memory can be accessed using R3 ie; you won't need
  502. to call this SWI to access as far as this. You can still do anyway, and this
  503. call is quite quick so little difference in speed will be noticed.
  504.    Note you can only access R4 bytes from where you asked for. This is
  505. because only that much data has been loaded within that block.
  506.    Setting bit 0 on entry means that a new reloc block is created of R4
  507. bytes, and one or more fragmented blocks are loaded into it to make it a
  508. contiguous area of data. Make sure that when you're finished with this block
  509. and the data (ie; before calling Tornado_Getaddr again), free the block. Note
  510. finally that setting bit 0 is quite slow in operation, and having blocks
  511. already in memory doesn't matter - they remain in memory - and thus, quite a
  512. lot of memory can be wasted. Use a routine capable of using fixed size data
  513. blocks to manipulate the data if possible.
  514.    This call also resets the time elapsed since last access to this block, or
  515. fragment of a block. This is used for virtual memory, where when the system
  516. heap becomes full the oldest blocks get dumped to disc. Using this call
  517. indicates that you want to use this block. If the block is currently on disc,
  518. it is reloaded into the heap and its address returned to you. Note no garbage
  519. collection occurs when this happens.
  520.    You can be guaranteed that this address will remain the same until the
  521. next specific call to Tornado_<call>, as all the calls done under
  522. interrupts/vectors etc. by Tornado do not garbage collect the heap.
  523.    PLEASE NOTE: When preempting code and referring to the system heap, you
  524. MUST use Tornado_GarbageHeap to force disabling of garbaging. If you do this,
  525. you must be prepared to regularly do a Tornado_GarbageHeap followed with
  526. another Tornado_Getaddr to ensure fragmentation does not become endemic. This
  527. is because other Tornado apps may cause the heap to be garbaged.
  528. Related calls:
  529.    All tornado heap calls;
  530.  
  531.  Tornado_Misc                        (SWI &C0008)
  532.  On entry:
  533.     R0=no of miscop you want
  534.  On exit:
  535.     Dependent on call
  536.  Use:
  537.     Used to call any one of the following calls:
  538.     &0002: HeapInfo. Takes the heap address in R1, and returns:
  539.        R0=size of heap
  540.        R1=heap addr, filled in if R1=0,1 on entry
  541.        R2=largest free block in heap
  542.        R3=amount of free space available
  543.        R4=number of relocatable blocks in heap
  544.        R5=number of non-relocatable blocks in heap
  545.        R6=bytes occupied by relocatable blocks
  546.        R7=bytes occupied by non-relocatable blocks
  547.        All other registers preserved
  548.  
  549.     &0003: Integer divide routine, R1=value, R2=divisor
  550.            Returns R1=divided value, R2=remainder
  551.     &0004: Garbage heap. Takes the heap in R1, preserves everything on return
  552.     &0005: addr of extblk routine (R1)
  553.     &0006: addr of integer divide routine (R1)
  554.     &0007: R1=addr of getaddr routine which allows you to determine the
  555.            address of a memory block much quicker.
  556.     &0008: Return info on RO & Tornado versions:
  557.        R1=Machine operating system type:
  558.           00: RISC-OS on a native ARM-based propriatary archietecture
  559.           01: RISC-OS on PCI ARM extension board
  560.           02: NCOS ???
  561.           08: ARM based multi-platform capable operating system that supports
  562.               RISC-OS calls
  563.           09: As above, but ARM code is emulated
  564.           10: As above, but ARM code is translated on load-in
  565.           11: ARM based Unix
  566.           16: Multiple platform portable advanced tornado operating system
  567.               (ATOS)
  568.        R2=OS as specified above version number * 100
  569.        R3=Tornado version number * 100
  570.  
  571.  Tornado_CallAfter                    (SWI &C0100)
  572.  On entry:
  573.     R0=flags
  574.       bit 0: clear to add routine, set to remove one
  575.       bit 1: reserved
  576.     R1=address to call
  577.     R2=time from now in units of 0.1 milliseconds (1 x 10^-4 seconds)
  578.     R3=value of R12 to be called with
  579.  On exit:
  580.     All registers preserved
  581.  Use:
  582.     This call will call the code pointed to by R1 in R2 x 0.1 milliseconds.
  583. Note that tornado will call your code in SVC mode with interrupts disabled
  584. and r14_svc stacked - therefore, you may call reentrant SWIs with no
  585. preparatory code (other than your r14 preserved to return to tornado). Your
  586. code must preserve all registers and flags apart from V and R0 on exit (see
  587. below), and should not cause interrupts to be enabled unless your code can
  588. deal with/prevent reentry and you do not wish to use the relatch facility
  589. below.
  590.     Please realise when writing your code with a low interval time
  591. (R2<100) that it *must* be very efficient, much more so than normal RO
  592. interrupts. Inefficient code called 10,000 times a second can kill a
  593. machine's performance - try it and see if you wish, and then imagine it on a
  594. Arm2 machine. To this end, do not access memory more than you can, do not
  595. access the stack more than you have to, and try and remove as many branch
  596. instructions as possible [1].
  597.     A very important fact that *must* be remembered when using this facility
  598. is that serial access on non-hardware-buffered serial chips (ie; the internal
  599. serial chip on every pre-RPC machine) *will* *not* function correctly with
  600. heavy interrupt usage such as that caused by low interval times with this
  601. routine. While this may not sound important, I would also add that all
  602. interrupt-based functions can be affected, including almost all peripheral
  603. access. To this end, take the idea of reenabling interrupts very seriously -
  604. the tornado shell does, despite its very short switching code.
  605.     Relatching: Tornado also supports a relatch on exit process in which you
  606. set R0 to the next interval and also set V. If you do not wish to use this,
  607. simply MOVS PC,R14. You must not enable interrupts if you use this facility.
  608.     Note also that you *must* *not* relatch if you are using callbacks.
  609. Callbacks by their nature take up to a centisecond to be dealt with normally,
  610. and thus you would overflow the callback handlers with requests for the same
  611. piece of code. To get around this, call Tornado_CallAfter from the the called
  612. back code to relatch the entry.
  613.     Finally, a small difference exists between the relatch interval and the
  614. interval passed to this SWI - the latter is unchecked, whereas the former is
  615. and thus bad intervals (ie; those equal to zero or below zero) are screened
  616. out. This is because internally extra code is required to screen the interval
  617. and the relatching code has to be very optimised. Note that a zero relatch
  618. interval will not work (1 is the smallest), and a minus one will cause
  619. extreme problems (memory overflows, no routine being called etc).
  620.     As an addendum, due to latency requirements, a guaranteed maximum of four
  621. routines can be on tornado's list. Your routine may be refused.
  622.     Note also that due to hardware limitations, it is very possible that this
  623. call may be interfered with by other software using the same facilities in
  624. the Acorn hardware (Sound samplers, video digitisers, multitasking Replay's
  625. etc).
  626.    [1]: These optimisations are probably only effective on Arm2-Arm7's as
  627. later ARMs use different architectures and much improved L1 and L2 caches'.
  628.  
  629.  Tornado_ReadMonotonicTime                (SWI &C0101)
  630.  On entry:
  631.     Nothing
  632.  On exit:
  633.     R0=low word of 1 x 10^-4 second counts since tornado was last activated
  634.     R1=high word of the above
  635.  Use:
  636.     This call reads a count value incremented by tornado 10,000 times a
  637. second.
  638.     Note also that due to hardware limitations, it is very possible that this
  639. call may be interfered with by other software using the same facilities in
  640. the Acorn hardware (Sound samplers, video digitisers, multitasking Replay's
  641. etc).
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.                           Tornado service calls:
  650. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  651.  
  652.  Tornado_Genocide (&0000):
  653.  On entry: nothing
  654.    This call is made to module extensions just before their finalise entries
  655. are called. Admittedly there isn't much point to it, but it's worth being
  656. here.
  657.    Note that this call is duplicated by a call in the RISC-OS service
  658. channels of number &C0000, and that's of even less use.
  659.  
  660.  Tornado_NewModule (&0001):
  661.  On entry: R2=data block of module
  662.    This call is made when a new extension module is registering itself. It
  663. can be vetoed by setting V on exit and R0 can contain an error message if you
  664. like - if not, set it to zero and a suitable alternative will be generated
  665. instead.
  666.  
  667.  Tornado_ModuleDying (&0002):
  668.  On entry: R2=data block of module
  669.    This call is made when an existing extension module is trying to
  670. deregister itself. It cannot be vetoed as this would leave partially active
  671. code in memory, never mind the fact that someone might be killing it the
  672. RISC-OS way. However, you can raise an objection if you wish by setting V and
  673. R0 to a suitable message, or none if you wish.
  674.  
  675.  Tornado_ResolutionChange (&0040):
  676.  On entry: R0=old style mode number now in force if applicable
  677.            R1=new style mode number now in force if applicable
  678.            R2=pixels across
  679.            R3=pixels high
  680.            R4=xeigen
  681.            R5=yeigen
  682.            R6=bits per pixel
  683.            R7=screen refresh rate in Hz (if available)
  684.            R8=pixel rate in Hz (if available)
  685.    This call is made when the video systems have changed their configuration
  686. in some way. The call is made after the change has occured so it cannot be
  687. vetoed (use the RISC-OS channels if you need to do this).
  688.    Note that any unavailable fields will be -1 as appropriate. Some versions
  689. of RISC-OS do not supply the same mode numbers, and some do not supply the
  690. pixel and refresh rates either.
  691.    Please try to not use R0 or R1 when writing your module - it will tie your
  692. module to one version of RISC-OS. However, not passing the mode number to
  693. things like ColourTrans is virtually impossible, so test which one of R0,R1
  694. is -1 and pass the other one to it. This will guarantee backwards
  695. compatibility.
  696.  
  697.  
  698.                          Tornado call providers
  699. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  700.  Tornado_Register                                       (&00000)
  701.  Tornado_Function                         (&00001)
  702.  Tornado_Initheap                         (&00002)
  703.  Tornado_Getblk                           (&00003)
  704.  Tornado_Freeblk                          (&00004)
  705.  Tornado_Extblk                           (&00005)
  706.  Tornado_HeapInfo                         (&0000X)
  707.  Tornado_ExtHeap                        (&00006)
  708.  Tornado_Getaddr                        (&00007)
  709.  Tornado_GarbageHeap                        (&0000X)
  710.  Tornado_Misc                            (&00008)
  711.  Tornado_CallAfter                        (&00100)
  712.  Tornado_ReadMonotonicTime                    (&00101)
  713.  
  714.  
  715.  
  716.  
  717.                          Tornado error numbers
  718. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  719.  Tornado_TornadoNotPresent                    (&C0000)
  720.     This error occurs when an extension module was loaded in without the
  721. tornado kernel present or active.
  722.  
  723.  Tornado_BadVersion                        (&C0001)
  724.     This error occurs when you try and set an impossible RISC-OS version
  725. using *Set Tornado$ROver or when someone tries to start up tornado on a bad
  726. version of RISC-OS.
  727.  
  728.  Tornado_HeapNotPossible                    (&C0002)
  729.     This error occurs when you try to initialise a heap that would be illegal
  730. if initialised. The error string will tell you exactly what the problem was.
  731.  
  732.  Tornado_BadGetblk                        (&C0003)
  733.     This error occurs when you try to claim a block that would be illegal -
  734. currently this is only when you specify a negative size.
  735.  
  736.  Tornado_BadHeap                        (&C0004)
  737.     This error occurs when you pass a heap in R1 that is not a tornado Heap+
  738. heap.
  739.  
  740.  Tornado_BadListFormat                        (&C0005)
  741.     This error occurs when tornado tries to deal with a data structure
  742. format that is either damaged, incorrect, out of date or in a format that
  743. the particular routine involved does not know how to deal with.
  744.  
  745.  Tornado_BadExtHeap                        (&C0006)
  746.     This error occurs when you try to change the size of a heap whose size is
  747. automatically changed by tornado without your intervention.
  748.  
  749.  Tornado_BadHandle                        (&C0007)
  750.     This error occurs when the handle you passed to a routine is incorrect
  751. for some reason - the error string specifies the exact problem.
  752.  
  753.  Tornado_CallAfterNotPresent                    (&C0100)
  754.     This error occurs when someone has tried to delink a routine not known to
  755. Tornado_CallAfter.
  756.  
  757.  Tornado_ShellAlreadyActive                    (&00900)
  758.     This error occurs when somone has tried to start the tornado shell when
  759. it is already active.
  760.  
  761.  Tornado_CallAfterNoRoom                    (&C0101)
  762.     This error occurs when there is no room to add a routine to the list.