daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Feb 21st, 2018 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. purpose: EHCI USB Controller intr pipes transaction processing
  2. copyright: Copyright 2006 FirmWorks. All rights reserved.
  3.  
  4. hex
  5. headers
  6.  
  7. \ XXX Need to implement periodic interrupt transactions
  8.  
  9. d# 500 constant intr-in-timeout
  10.  
  11. 0 instance value intr-in-pipe
  12. 0 instance value intr-in-interval
  13.  
  14. 0 instance value intr-in-qh
  15. 0 instance value intr-in-qtd
  16.  
  17. : intr-in-data@        ( -- n )  intr-in-pipe  target di-in-data@  di-data>td-data  ;
  18. : intr-in-data!        ( n -- )  td-data>di-data intr-in-pipe  target di-in-data!  ;
  19. : toggle-intr-in-data  ( -- )    intr-in-pipe  target di-in-data-toggle  ;
  20. : fixup-intr-in-data   ( qh -- n )
  21.    usb-error USB_ERR_STALL and  if
  22.       drop TD_TOGGLE_DATA0
  23.    else
  24.       >hcqh-overlay >hcqtd-token le-l@
  25.    then
  26.    intr-in-data!
  27. ;
  28.  
  29. : process-intr-args  ( buf len pipe timeout -- )  process-bulk-args  ;
  30. : alloc-intr-qhqtds  ( -- qh qtd )  alloc-bulk-qhqtds  ;
  31. : fill-intr-io-qtds  ( dir qtd -- )
  32.    my-#qtds 0  do               ( dir qtd )
  33.       my-buf my-buf-phys /my-buf 3 pick fill-qtd-bptrs
  34.                         ( dir qtd /bptr )
  35.       2 pick over d# 16 << or           ( dir qtd /bptr token )
  36.       TD_C_ERR3 or TD_STAT_ACTIVE or        ( dir qtd /bptr token' )
  37.       intr-in-data@  toggle-intr-in-data  or    ( dir qtd /bptr token' )
  38.       2 pick >hcqtd-token le-l!         ( dir qtd /bptr )
  39.       my-buf++                  ( dir qtd )
  40.       dup fixup-last-qtd            ( dir qtd )
  41.       >qtd-next l@              ( dir qtd' )
  42.    loop  2drop                  ( )
  43. ;
  44.  
  45. external
  46.  
  47. : begin-intr-in  ( buf len pipe interval -- )
  48.    debug?  if  ." begin-intr-in" cr  then
  49.    intr-in-qh  if  4drop exit  then     \ Already started
  50.  
  51.    to intr-in-interval
  52.    dup to intr-in-pipe
  53.    intr-in-timeout process-intr-args
  54.    alloc-intr-qhqtds  to intr-in-qtd  to intr-in-qh
  55.  
  56.    \ IN qTDs
  57.    TD_PID_IN intr-in-qtd fill-intr-io-qtds
  58.  
  59.    \ Start intr in transaction
  60.    intr-in-qh pt-intr fill-qh
  61.    intr-in-qh my-speed intr-in-interval insert-intr-qh
  62. ;
  63.  
  64. : intr-in?  ( -- actual usberr )
  65.    intr-in-qh 0=  if  0 USB_ERR_INV_OP exit  then
  66.    clear-usb-error
  67.    process-hc-status
  68.    intr-in-qh dup sync-qhqtds
  69.    qh-done?  if
  70.       intr-in-qh error?  if
  71.          0
  72.       else
  73.          intr-in-qtd  dup intr-in-qh >qh-#qtds l@ get-actual
  74.          over >qtd-buf rot >qtd-pbuf l@ 2 pick dma-sync
  75.       then
  76.       intr-in-qh fixup-intr-in-data
  77.    else
  78.       0
  79.    then
  80.    usb-error
  81. ;
  82.  
  83. headers
  84. : restart-intr-in-qtd  ( qtd -- )
  85.    begin  ?dup  while
  86.       dup >hcqtd-bptr0 dup le-l@ h# ffff.f000 and swap le-l!
  87.       dup >qtd-/buf l@ d# 16 <<
  88.       TD_STAT_ACTIVE or TD_C_ERR3 or TD_PID_IN or
  89.       intr-in-data@ or
  90.       over >hcqtd-token le-l!
  91.       >qtd-next l@
  92.    repeat
  93. ;
  94.  
  95. external
  96. : restart-intr-in  ( -- )
  97.    intr-in-qh 0=  if  exit  then
  98.  
  99.    \ Setup qTD again
  100.    intr-in-qtd restart-intr-in-qtd
  101.  
  102.    \ Setup QH again
  103.    intr-in-qh >hcqh-endp-char dup le-l@ QH_TD_TOGGLE invert and swap le-l!
  104.    intr-in-qtd >qtd-phys l@ intr-in-qh >hcqh-overlay >hcqtd-next le-l!
  105.    intr-in-qh sync-qhqtds
  106. ;
  107.  
  108. : end-intr-in  ( -- )
  109.    debug?  if  ." end-intr-in" cr  then
  110.    intr-in-qh 0=  if  exit  then
  111.    intr-in-qh dup fixup-intr-in-data
  112.    intr-in-qtd map-out-bptrs
  113.    dup remove-intr-qh  free-qhqtds
  114.    0 to intr-in-qh  0 to intr-in-qtd
  115. ;
  116.  
  117. headers
  118.  
  119. : (end-extra)  ( -- )  (end-extra) end-intr-in  ;
  120. ' (end-extra) to end-extra
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top