home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 330_03 / tskstub.asm < prev    next >
Assembly Source File  |  1990-10-12  |  7KB  |  353 lines

  1. ;
  2. ;    --- Version 2.2 90-10-12 10:46 ---
  3. ;
  4. ;    CTask - Code sharing function stubs
  5. ;
  6. ;    Public Domain Software written by
  7. ;        Thomas Wagner
  8. ;        Ferrari electronic Gmbh
  9. ;        Beusselstrasse 27
  10. ;        D-1000 Berlin 21
  11. ;        Germany
  12. ;
  13. ;    This file is new with version 2.1.
  14. ;    It is used to generate the function entry stubs to allow
  15. ;    applications to share the code of the first, resident,
  16. ;    CTask invocation.
  17. ;
  18. ;    Two object files are generated from this source:
  19. ;
  20. ;    If GEN_JTAB is defined on assembly, an entry address table is 
  21. ;    generated that is to be linked with the primary invocation.
  22. ;
  23. ;    If no Define is given on assembly, the function stubs for the 
  24. ;    application are generated.
  25. ;
  26. ;    There are two macros, 'stub' and 'dstub'. The 'stub' macro
  27. ;    creates an actual entry/external, whereas the 'dstub' macro
  28. ;    only creates a dummy table entry, and no public label.
  29. ;
  30. ;    You should define all entries you are using anyway in your
  31. ;    primary invocation with 'stub'.
  32. ;    Functions that are not used in either primary or secondary
  33. ;    may be defined with 'dstub'.
  34. ;    YOU SHOULD NOT delete entries or change the order of entries.
  35. ;
  36. ;    It is possible to have a mix of code sharing and locally loaded
  37. ;    routines in an application. The routines in tskmain.c and tsksub.c
  38. ;    should, however, always be enabled with 'stub', since they are always
  39. ;    included in the primary, and could cause problems when directly
  40. ;    linked.
  41. ;
  42. ;    CAUTION: The application may use small model, i.e. near entries
  43. ;         into the stub table. The NEAR_CODE define may be
  44. ;         set to 1 when compiling this module for the application.
  45. ;
  46. ;         The primary kernel MUST use far routines for code
  47. ;         sharing to work, and the entry points must load DS on
  48. ;         entry.
  49. ;
  50.     include    tsk.mac
  51. ;
  52.     .tsk_model
  53. ;
  54. ;
  55.     IFDEF    GEN_JTAB
  56.     public    tsk_jmptab
  57.     ENDIF
  58. ;
  59. nstubs    =    0
  60. ;
  61. stub    macro    extn,ccc
  62.     IFNB    <ccc>
  63.     IFDEF    GEN_JTAB
  64.     CGlbext    extn
  65.     ELSE
  66.     CPubfnc    extn
  67.     ENDIF
  68.     ELSE
  69.     IFDEF    GEN_JTAB
  70.     Globext    extn
  71.     ELSE
  72.     Pubfunc    extn
  73.     ENDIF
  74.     ENDIF
  75.     IF1
  76. estr    catstr    <stb>,%nstubs
  77. % estr    equ    <extn>
  78.     ENDIF
  79. nstubs    =    nstubs+1
  80.     endm
  81. ;
  82. dstub    macro    extn
  83. nstubs    =    nstubs+1
  84.     endm
  85. ;
  86. ;------------------------------------------------------------------
  87. ;
  88. ;    The routines from the module
  89. ;        tskres
  90. ;    must be linked directly, since they establish the
  91. ;    stub linkage.
  92. ;
  93. ;    The routines from the modules
  94. ;        tskmain
  95. ;        tskgrp
  96. ;    must not be defined as function stubs. Those routines
  97. ;    need local routine/variable info, and thus must be linked
  98. ;    with the secondary invocation. For secondary invocations
  99. ;    not creating groups, the routines defined there are not needed
  100. ;    anyway.
  101. ;
  102. ;    The local routines defined in
  103. ;        tsksub
  104. ;        tskque
  105. ;    are normally defined as 'near'. Including those routines
  106. ;    into the stub list would require them to be defined as
  107. ;    far _loadds (Huge for TC). This would slow down the most basic
  108. ;    operations, and is not recommended.
  109. ;
  110. ;------------------------------------------------------------------
  111. ;
  112. ;    The following entries should always be 'stub', not 'dstub',
  113. ;    since they are in the primary anyway.
  114. ;
  115. ;    module tskinst
  116. ;
  117.     stub    tsk_install_main
  118.     stub    tsk_remove_tasker
  119. ;
  120. ;    module tskutil
  121. ;
  122.     stub    preempt_on
  123.     stub    preempt_off
  124.     stub    tsk_ena_preempt
  125.     stub    tsk_dis_preempt
  126.     stub    t_delay
  127. ;
  128. ;    module tsktask
  129. ;
  130.     stub    create_task
  131.     stub    kill_task
  132.     stub    start_task
  133.     stub    wake_task
  134. ;
  135. ;    module tskasm
  136. ;
  137.     stub    schedule
  138.     stub    yield
  139.     stub    tsk_dis_int
  140.     stub    tsk_ena_int
  141.     stub    tsk_nop
  142.     stub    tsk_inpw
  143.     stub    tsk_flags
  144.     stub    tsk_dseg
  145. ;
  146. ;-------------------------------------------------------------------
  147. ;
  148. ;    The following functions may be either 'stub' or 'dstub',
  149. ;    but are normally used by kernel routines anyway, so you can
  150. ;    keep them as 'stub'.
  151. ;
  152. ;    module tskrsc
  153. ;    Resources are used in the DOS module
  154. ;
  155.     stub    create_resource
  156.     stub    delete_resource
  157.     stub    release_resource
  158.     stub    request_resource
  159.     stub    request_cresource
  160.     stub    c_request_resource
  161.     stub    c_request_cresource
  162.     stub    check_resource
  163. ;
  164. ;    module tskflg
  165. ;    Flags are in the DOS module, too
  166. ;
  167.     stub    create_flag
  168.     stub    delete_flag
  169.     stub    set_flag
  170.     stub    clear_flag
  171.     stub    clear_flag_wait_set
  172.     stub    wait_flag_set
  173.     stub    wait_flag_clear
  174.     stub    check_flag
  175. ;
  176. ;    module tskcnt
  177. ;    Counters are used for the timer tasks
  178. ;
  179.     stub    create_counter
  180.     stub    delete_counter
  181.     stub    clear_counter
  182.     stub    wait_counter_set
  183.     stub    wait_counter_clear
  184.     stub    inc_counter
  185.     stub    set_counter
  186.     stub    check_counter
  187. ;
  188. ;-------------------------------------------------------------------
  189. ;
  190. ;    The following functions may be either 'stub' or 'dstub'.
  191. ;    They are not referenced by kernel routines, but if you have
  192. ;    them in the primary, you can keep them as 'stub'.
  193. ;
  194. ;    module tskname
  195. ;
  196.     dstub    find_group_name
  197.     dstub    find_name
  198. ;
  199. ;    module tsksec
  200. ;
  201.     dstub    t_read_key
  202.     dstub    t_wait_key
  203.     dstub    t_keyhit
  204. ;
  205. ;    module tsktutl
  206. ;
  207.     dstub    get_priority
  208.     dstub    set_priority
  209.     dstub    set_funcs
  210.     dstub    set_user_ptr
  211.     dstub    get_user_ptr
  212.     dstub    curr_task
  213.     dstub    stop_task
  214. ;
  215. ;    module tsktops
  216. ;
  217.     dstub    create_timer,c
  218.     dstub    delete_timer
  219.     dstub    change_timer,c
  220. ;
  221. ;    module tsktsub
  222. ;
  223.     dstub    delete_watch
  224. ;
  225. ;    module tskmemw
  226. ;
  227.     dstub    create_memory_watch,c
  228.     dstub    wait_memory
  229. ;
  230. ;    module tskporw
  231. ;
  232.     dstub    create_port_watch,c
  233.     dstub    wait_port
  234. ;
  235. ;    module tskhot
  236. ;
  237.     dstub    create_hotkey_entry,c
  238.     dstub    wait_hotkey
  239. ;
  240. ;    module    tskmail
  241. ;
  242.     dstub    create_mailbox
  243.     dstub    delete_mailbox
  244.     dstub    send_mail
  245.     dstub    wait_mail
  246.     dstub    c_wait_mail
  247.     dstub    check_mailbox
  248. ;
  249. ;    module    tskpip
  250. ;
  251.     dstub    create_pipe
  252.     dstub    delete_pipe
  253.     dstub    read_pipe
  254.     dstub    c_read_pipe
  255.     dstub    write_pipe
  256.     dstub    c_write_pipe
  257.     dstub    wait_pipe_empty
  258.     dstub    check_pipe
  259.     dstub    pipe_free
  260.     dstub    flush_pipe
  261. ;
  262. ;    module    tskwpip
  263. ;
  264.     dstub    create_wpipe
  265.     dstub    delete_wpipe
  266.     dstub    read_wpipe
  267.     dstub    c_read_wpipe
  268.     dstub    write_wpipe
  269.     dstub    c_write_wpipe
  270.     dstub    wait_wpipe_empty
  271.     dstub    check_wpipe
  272.     dstub    wpipe_free
  273.     dstub    flush_wpipe
  274. ;
  275. ;    module    tskbuf
  276. ;
  277.     dstub    create_buffer
  278.     dstub    delete_buffer
  279.     dstub    read_buffer
  280.     dstub    c_read_buffer
  281.     dstub    write_buffer
  282.     dstub    c_write_buffer
  283.     dstub    check_buffer
  284. ;
  285. ;    module    tsktick
  286. ;
  287.     dstub    create_ticker
  288.     dstub    delete_ticker
  289.     dstub    set_ticker
  290.     dstub    get_ticker
  291. ;
  292. ;-------------------------------------------------------------------
  293. ;
  294.     IFNDEF    GEN_JTAB
  295.     .tsk_data
  296.     extrn    tsk_global: dword
  297. ;
  298.     .tsk_edata
  299.     ENDIF
  300.     .tsk_code
  301. ;
  302. nstb    =    0
  303. ;
  304.     IFDEF    GEN_JTAB
  305. ;
  306. ;    The 'fault' entry just does an INT 3, which breaks to a debugger
  307. ;    if one is installed. If no debugger is running, you're out of luck.
  308. ;    But... you should never get here unless you have different 
  309. ;    stub/dstub combinations in primary and secondary.
  310. ;
  311. @fault    proc    far
  312.     int    3
  313.     ret
  314. @fault    endp
  315. ;
  316. ;
  317. tsk_jmptab    label    dword
  318.     ENDIF
  319. ;
  320.     rept    nstubs
  321. estr    catstr    <stb>,%nstb
  322.     IFDEF    GEN_JTAB
  323. %    IFDEF    estr
  324.     dd    estr
  325.     ELSE
  326.     dd    @fault
  327.     ENDIF
  328.     ELSE
  329.     IFDEF    estr
  330. % estr:
  331.     IF    NEAR_CODE
  332.     pop    bx
  333.     push    cs
  334.     push    bx
  335.     ENDIF
  336.     IFDEF    LOAD_DS
  337.     mov    bx,@CTASK_DATA
  338.     mov    es,bx
  339.     les    bx,es:tsk_global
  340.     ELSE
  341.     les    bx,tsk_global
  342.     ENDIF
  343.     les    bx,es:stub_table[bx]
  344.     jmp    dword ptr es:[bx+(nstb*4)]
  345.     ENDIF
  346.     ENDIF
  347. nstb    =    nstb+1
  348.     endm
  349. ;
  350.     .tsk_ecode
  351.     end
  352.  
  353.