home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / sdk / winh / alpha / kxalpha.h < prev   
Encoding:
C/C++ Source or Header  |  1995-07-11  |  39.7 KB  |  2,086 lines

  1. /*++
  2.  
  3.   Copyright (c) 1992, 1993 Digital Equipment Corporation
  4.  
  5.  
  6.   Module:
  7.            kxalpha.h
  8.  
  9.   Abstract:
  10.            Contains alpha architecture constants and assembly macros.
  11.  
  12.   Author:
  13.           Joe Notarangelo  31-March-1992   (based on Dave Cutler's kxmips.h)
  14.  
  15.  
  16.   Revision History
  17.  
  18.   16-July-1992       John DeRosa
  19.  
  20.   Removed fwcalpal.h hook.
  21.  
  22.  
  23.   8-July-1992        John DeRosa
  24.  
  25.   Added fwcalpal.h hooks, defined HALT call_pal.
  26.  
  27.  
  28. --*/
  29.  
  30. //
  31. // Define Sfw Interrupt Levels and masks
  32. //
  33.  
  34. #define APC_INTERRUPT 0x1
  35. #define DISPATCH_INTERRUPT 0x2
  36.  
  37. //
  38. // Define standard integer registers.
  39. //
  40. // N.B. `at' is `AT' so it doesn't conflict with the `.set at' pseudo-op.
  41. //
  42.  
  43. #define v0 $0                   // return value register
  44. #define t0 $1                   // caller saved (temporary) registers
  45. #define t1 $2                   //
  46. #define t2 $3                   //
  47. #define t3 $4                   //
  48. #define t4 $5                   //
  49. #define t5 $6                   //
  50. #define t6 $7                   //
  51. #define t7 $8                   //
  52. #define s0 $9                   // callee saved (nonvolatile) registers
  53. #define s1 $10                  //
  54. #define s2 $11                  //
  55. #define s3 $12                  //
  56. #define s4 $13                  //
  57. #define s5 $14                  //
  58. #define fp $15                  // frame pointer register, or s6
  59. #define a0 $16                  // argument registers
  60. #define a1 $17                  //
  61. #define a2 $18                  //
  62. #define a3 $19                  //
  63. #define a4 $20                  //
  64. #define a5 $21                  //
  65. #define t8 $22                  // caller saved (temporary) registers
  66. #define t9 $23                  //
  67. #define t10 $24                 //
  68. #define t11 $25                 //
  69. #define ra $26                  // return address register
  70. #define t12 $27                 // caller saved (temporary) registers
  71. #define AT $28                  // assembler temporary register
  72. #define gp $29                  // global pointer register
  73. #define sp $30                  // stack pointer register
  74. #define zero $31                // zero register
  75.  
  76. #ifndef PALCODE
  77.  
  78. //
  79. // Define standard floating point registers.
  80. //
  81.  
  82. #define f0 $f0                  // return value register
  83. #define f1 $f1                  // return value register
  84. #define f2 $f2                  // callee saved (nonvolatile) registers
  85. #define f3 $f3                  //
  86. #define f4 $f4                  //
  87. #define f5 $f5                  //
  88. #define f6 $f6                  //
  89. #define f7 $f7                  //
  90. #define f8 $f8                  //
  91. #define f9 $f9                  //
  92. #define f10 $f10                // caller saved (temporary) registers
  93. #define f11 $f11                //
  94. #define f12 $f12                //
  95. #define f13 $f13                //
  96. #define f14 $f14                //
  97. #define f15 $f15                //
  98. #define f16 $f16                // argument registers
  99. #define f17 $f17                //
  100. #define f18 $f18                //
  101. #define f19 $f19                //
  102. #define f20 $f20                //
  103. #define f21 $f21                //
  104. #define f22 $f22                // caller saved (temporary) registers
  105. #define f23 $f23                //
  106. #define f24 $f24                //
  107. #define f25 $f25                //
  108. #define f26 $f26                //
  109. #define f27 $f27                //
  110. #define f28 $f28                //
  111. #define f29 $f29                //
  112. #define f30 $f30                //
  113. #define f31 $f31                // floating zero register
  114. #define fzero $f31              // floating zero register (alias)
  115.  
  116. #endif //!PALCODE
  117.  
  118.  
  119. //
  120. // Define procedure entry macros
  121. //
  122.  
  123. #define ALTERNATE_ENTRY(Name)           \
  124.         .globl  Name;                   \
  125. Name:;
  126.  
  127. #define LEAF_ENTRY(Name)                \
  128.         .text;                          \
  129.         .align  4;                      \
  130.         .globl  Name;                   \
  131.         .ent    Name, 0;                \
  132. Name:;                                  \
  133.         .frame  sp, 0, ra;              \
  134.         .prologue 0;
  135.  
  136. #define NESTED_ENTRY(Name, fsize, retrg) \
  137.         .text;                          \
  138.         .align  4;                      \
  139.         .globl  Name;                   \
  140.         .ent    Name, 0;                \
  141. Name:;                                  \
  142.         .frame  sp, fsize, retrg;
  143.  
  144. //
  145. // Define global definition macros.
  146. //
  147.  
  148. #define END_REGION(Name)                \
  149.         .globl  Name;                   \
  150. Name:;
  151.  
  152. #define START_REGION(Name)              \
  153.         .globl  Name;                   \
  154. Name:;
  155.  
  156. //
  157. // Define exception handling macros.
  158. //
  159.  
  160. #define EXCEPTION_HANDLER(Handler)      \
  161.         .edata 1, Handler;
  162.  
  163.  
  164. #define PROLOGUE_END  .prologue 1;
  165.  
  166. //
  167. // Define save and restore floating state macros.
  168. //
  169.  
  170. #define SAVE_NONVOLATILE_FLOAT_STATE    \
  171.         bsr     ra, KiSaveNonVolatileFloatState
  172.  
  173. //
  174. // Define interfaces to pcr and palcode
  175. //
  176. //    The interfaces defined in the following macros will be PALcode
  177. //    calls for some implemenations, but may be in-line code in others
  178. //    (eg. uniprocessor vs multiprocessor).  At the current time all of
  179. //    the interfaces are PALcode calls.
  180. //
  181.  
  182. //
  183. // Define interfaces for cache coherency
  184. //
  185.  
  186. //++
  187. //
  188. // IMB
  189. //
  190. // Macro Description:
  191. //
  192. //     Issue the architecture-defined Instruction Memory Barrier.  This
  193. //     instruction will make the processor instruction stream coherent with
  194. //     the system memory.
  195. //
  196. // Mode:
  197. //
  198. //     Kernel and User.
  199. //
  200. // Arguments:
  201. //
  202. //     None.
  203. //
  204. // Return Value:
  205. //
  206. //     None.
  207. //
  208. // Registers Used:
  209. //
  210. //     None.
  211. //
  212. //--
  213.  
  214. #define IMB          call_pal imb
  215.  
  216. //
  217. // Define PALcode Environment Transition Interfaces
  218. //
  219.  
  220. //++
  221. //
  222. // REBOOT
  223. //
  224. // Macro Description:
  225. //
  226. //     Reboot the processor to return to firmware.
  227. //
  228. // Mode:
  229. //
  230. //     Kernel only.
  231. //
  232. // Arguments:
  233. //
  234. //     None.
  235. //
  236. // Return Value:
  237. //
  238. //     Does not return.
  239. //
  240. // Registers Used:
  241. //
  242. //     None.
  243. //
  244. //--
  245.  
  246. #define REBOOT         call_pal reboot
  247.  
  248. //++
  249. //
  250. // RESTART
  251. //
  252. // Macro Description:
  253. //
  254. //     Restart the processor with the processor state found in a
  255. //     restart block.
  256. //
  257. // Mode:
  258. //
  259. //     Kernel only.
  260. //
  261. // Arguments:
  262. //
  263. //     a0 - Supplies a pointer to an ARC restart block with an Alpha AXP
  264. //          saved state area.
  265. //
  266. // Return Value:
  267. //
  268. //     If successful the call does not return.  Otherwise, any return
  269. //     is considered a failure.
  270. //
  271. // Registers Used:
  272. //
  273. //     None.
  274. //
  275. //--
  276.  
  277. #define RESTART      call_pal restart
  278.  
  279. //++
  280. //
  281. // SWPPAL
  282. //
  283. // Macro Description:
  284. //
  285. //     Swap the execution environment to a new PALcode image.
  286. //
  287. // Mode:
  288. //
  289. //     Kernel only.
  290. //
  291. // Arguments:
  292. //
  293. //     a0 - Supplies the physical address of the base of the new PALcode
  294. //          image.
  295. //
  296. //     a1 - a5 - Supply arguments to the new PALcode environment.
  297. //
  298. // Return Value:
  299. //
  300. //     Does not return.
  301. //
  302. // Registers Used:
  303. //
  304. //     None.
  305. //
  306. //--
  307.  
  308. #define SWPPAL       call_pal swppal
  309.  
  310. //
  311. // Define IRQL and interrupt interfaces
  312. //
  313.  
  314. //++
  315. //
  316. // DISABLE_INTERRUPTS
  317. //
  318. // Macro Description:
  319. //
  320. //     Disable all interrupts for the current processor and return the
  321. //     previous PSR.
  322. //
  323. // Mode:
  324. //
  325. //     Kernel only.
  326. //
  327. // Arguments:
  328. //
  329. //     None.
  330. //
  331. // Return Value:
  332. //
  333. //     None.
  334. //
  335. // Registers Used:
  336. //
  337. //     None.
  338. //
  339. //--
  340.  
  341. #define DISABLE_INTERRUPTS        call_pal di
  342.  
  343. //++
  344. //
  345. // ENABLE_INTERRUPTS
  346. //
  347. // Macro Description:
  348. //
  349. //     Enable interrupts according to the current PSR for the current
  350. //     processor.
  351. //
  352. // Mode:
  353. //
  354. //     Kernel only.
  355. //
  356. // Arguments:
  357. //
  358. //     None.
  359. //
  360. // Return Value:
  361. //
  362. //     None.
  363. //
  364. // Registers Used:
  365. //
  366. //     None.
  367. //
  368. //--
  369.  
  370. #define ENABLE_INTERRUPTS         call_pal ei
  371.  
  372. //++
  373. //
  374. // SWAP_IRQL
  375. //
  376. // Macro Description:
  377. //
  378. //     Swap the IRQL level for the current processor.
  379. //
  380. // Mode:
  381. //
  382. //     Kernel only.
  383. //
  384. // Arguments:
  385. //
  386. //     a0 - Supplies the new IRQL level.
  387. //
  388. // Return Value:
  389. //
  390. //     v0 = previous IRQL level.
  391. //
  392. // Registers Used:
  393. //
  394. //     AT, a1 - a3.
  395. //
  396. //--
  397.  
  398. #define SWAP_IRQL    call_pal swpirql
  399.  
  400. //++
  401. //
  402. // GET_CURRENT_IRQL
  403. //
  404. // Macro Description:
  405. //
  406. //     Return the current processor Interrupt Request Level (IRQL).
  407. //
  408. // Mode:
  409. //
  410. //     Kernel only.
  411. //
  412. // Arguments:
  413. //
  414. //     None.
  415. //
  416. // Return Value:
  417. //
  418. //     v0 = current IRQL.
  419. //
  420. // Registers Used:
  421. //
  422. //     AT.
  423. //
  424. //--
  425.  
  426. #define GET_CURRENT_IRQL  call_pal rdirql
  427.  
  428.  
  429. //
  430. // Define interfaces for software interrupts
  431. //
  432.  
  433. //++
  434. //
  435. // DEASSERT_SOFTWARE_INTERRUPT
  436. //
  437. // Macro Description:
  438. //
  439. //     Deassert the software interrupts indicated in a0 for the current
  440. //     processor.
  441. //
  442. // Mode:
  443. //
  444. //     Kernel only.
  445. //
  446. // Arguments:
  447. //
  448. //     a0 - Supplies the mask for the software interrupt to be de-asserted.
  449. //          a0<1> - Deassert DISPATCH software interrupt.
  450. //          a0<0> - Deassert APC software interrupt.
  451. //
  452. // Return Value:
  453. //
  454. //     None.
  455. //
  456. // Registers Used:
  457. //
  458. //     AT, a1 - a3.
  459. //
  460. //--
  461.  
  462. #define DEASSERT_SOFTWARE_INTERRUPT    call_pal csir
  463.  
  464. //++
  465. //
  466. // REQUEST_SOFTWARE_INTERRUPT
  467. //
  468. // Macro Description:
  469. //
  470. //     Request software interrupts on the current processor according to
  471. //     the mask supplied in a0.
  472. //
  473. // Mode:
  474. //
  475. //     Kernel only.
  476. //
  477. // Arguments:
  478. //
  479. //     a0 - Supplies the mask of software interrupts to be requested.
  480. //          a0<1> - Request DISPATCH software interrupt.
  481. //          a0<0> - Request APC software interrupt.
  482. //
  483. // Return Value:
  484. //
  485. //     None.
  486. //
  487. // Registers Used:
  488. //
  489. //     AT, a1 - a3.
  490. //
  491. //--
  492.  
  493. #define REQUEST_SOFTWARE_INTERRUPT     call_pal ssir
  494.  
  495. //
  496. // Define interfaces to Processor Status Register
  497. //
  498.  
  499. //++
  500. //
  501. // GET_CURRENT_PROCESSOR_STATUS_REGISTER
  502. //
  503. // Macro Description:
  504. //
  505. //     Return the current Processor Status Register (PSR) for the current
  506. //     processor.
  507. //
  508. // Mode:
  509. //
  510. //     Kernel only.
  511. //
  512. // Arguments:
  513. //
  514. //     None.
  515. //
  516. // Return Value:
  517. //
  518. //     v0 = current PSR.
  519. //
  520. // Registers Used:
  521. //
  522. //     AT.
  523. //
  524. //--
  525.  
  526. #define GET_CURRENT_PROCESSOR_STATUS_REGISTER   call_pal rdpsr
  527.  
  528.  
  529. //
  530. // Define current thread interface
  531. //
  532.  
  533. //++
  534. //
  535. // GET_THREAD_ENVIRONMENT_BLOCK
  536. //
  537. // Macro Description:
  538. //
  539. //     Return the base address of the current Thread Environment Block (TEB),
  540. //     for the currently executing thread on the current processor.
  541. //
  542. // Mode;
  543. //
  544. //     Kernel and User.
  545. //
  546. // Arguments:
  547. //
  548. //     None.
  549. //
  550. // Return Value:
  551. //
  552. //     v0 = TEB base address.
  553. //
  554. // Registers Used:
  555. //
  556. //     None.
  557. //
  558. //--
  559.  
  560. #define GET_THREAD_ENVIRONMENT_BLOCK  call_pal rdteb
  561.  
  562. //++
  563. //
  564. // GET_CURRENT_THREAD
  565. //
  566. // Macro Description:
  567. //
  568. //     Return the thread object address for the currently executing thread
  569. //     on the current processor.
  570. //
  571. // Mode:
  572. //
  573. //     Kernel only.
  574. //
  575. // Arguments:
  576. //
  577. //     None.
  578. //
  579. // Return Value:
  580. //
  581. //     v0 = PCR base address.
  582. //
  583. // Registers Used:
  584. //
  585. //     AT.
  586. //
  587. //--
  588.  
  589. #ifdef NT_UP
  590.  
  591. //
  592. // If uni-processor, retrieve current thread address from the global
  593. // variable KiCurrentThread.
  594. //
  595.  
  596. #define GET_CURRENT_THREAD              \
  597.         lda     v0, KiCurrentThread;    \
  598.         ldl     v0, 0(v0)
  599.  
  600. #else
  601.  
  602. //
  603. // If multi-processor, retrive per-processor current thread via a call pal.
  604. //
  605.  
  606. #define GET_CURRENT_THREAD    call_pal rdthread
  607.  
  608. #endif //NT_UP
  609.  
  610. //
  611. // Define per-processor data area routine interfaces
  612. //
  613.  
  614. //++
  615. //
  616. // GET_PROCESSOR_CONTROL_REGION_BASE
  617. //
  618. // Macro Description:
  619. //
  620. //     Return the base address of the Process Control Region (PCR)
  621. //     for the current processor.
  622. //
  623. // Mode:
  624. //
  625. //     Kernel only.
  626. //
  627. // Arguments:
  628. //
  629. //     None.
  630. //
  631. // Return Value:
  632. //
  633. //     v0 = PCR base address.
  634. //
  635. // Registers Used:
  636. //
  637. //     AT.
  638. //
  639. //--
  640.  
  641. #ifdef NT_UP
  642.  
  643. //
  644. // Uni-processor, address of PCR is in global variable.
  645. //
  646.  
  647. #define GET_PROCESSOR_CONTROL_REGION_BASE \
  648.         lda     v0, KiPcrBaseAddress;     \
  649.         ldl     v0, 0(v0)
  650.  
  651. #else
  652.  
  653. //
  654. // Multi-processor, get per-processor value via call pal.
  655. //
  656.  
  657. #define GET_PROCESSOR_CONTROL_REGION_BASE    call_pal rdpcr
  658.  
  659. #endif //NT_UP
  660.  
  661. //++
  662. //
  663. // GET_PROCESSOR_CONTROL_BLOCK_BASE
  664. //
  665. // Macro Description:
  666. //
  667. //     Return the Processor Control Block base address.
  668. //
  669. // Mode:
  670. //
  671. //     Kernel only.
  672. //
  673. // Arguments:
  674. //
  675. //     None.
  676. //
  677. // Return Value:
  678. //
  679. //     v0 = PRCB base address.
  680. //
  681. // Registers Used:
  682. //
  683. //     AT.
  684. //
  685. //--
  686.  
  687. #define GET_PROCESSOR_CONTROL_BLOCK_BASE   \
  688.         GET_PROCESSOR_CONTROL_REGION_BASE; \
  689.         ldl     v0, PcPrcb(v0)
  690.  
  691.  
  692. //
  693. // Define kernel stack interfaces
  694. //
  695.  
  696. //++
  697. //
  698. // GET_INITIAL_KERNEL_STACK
  699. //
  700. // Macro Description:
  701. //
  702. //     Return the initial kernel stack address for the current thread.
  703. //
  704. // Mode:
  705. //
  706. //     Kernel only.
  707. //
  708. // Arguments:
  709. //
  710. //     None.
  711. //
  712. // Return Value:
  713. //
  714. //     v0 = initial kernel stack address.
  715. //
  716. // Registers Used:
  717. //
  718. //     AT.
  719. //
  720. //--
  721.  
  722. #define GET_INITIAL_KERNEL_STACK  call_pal rdksp
  723.  
  724. //++
  725. //
  726. // SET_INITIAL_KERNEL_STACK
  727. //
  728. // Macro Description:
  729. //
  730. //     Set the initial kernel stack address for the current thread.
  731. //
  732. // Mode:
  733. //
  734. //     Kernel only.
  735. //
  736. // Arguments:
  737. //
  738. //     a0 - Supplies the new initial kernel stack address.
  739. //
  740. // Return Value:
  741. //
  742. //     v0 - Previous initial kernel stack address.
  743. //
  744. // Registers Used:
  745. //
  746. //     AT.
  747. //
  748. //--
  749.  
  750. #define SET_INITIAL_KERNEL_STACK  call_pal swpksp
  751.  
  752. //
  753. // Define initialization routine interfaces
  754. //
  755.  
  756. //++
  757. //
  758. // INITIALIZE_PAL
  759. //
  760. // Macro Description:
  761. //
  762. //     Supply values to initialize the PALcode.
  763. //
  764. // Mode:
  765. //
  766. //     Kernel only.
  767. //
  768. // Arguments:
  769. //
  770. //     a0 - Supplies initial PageDirectoryBase (32-bit superpage address).
  771. //     a1 - Supplies PRCB Base Address (32-bit superpage address).
  772. //     a2 - Supplies address of initial kernel thread object.
  773. //     a3 - Supplies address of TEB for initial kernel thread object.
  774. //     gp - Supplies kernel image global pointer.
  775. //     sp - Supplies initial thread kernel stack pointer.
  776. //
  777. // Return Value:
  778. //
  779. //     v0 = PAL base address in 32-bit super-page format (KSEG0).
  780. //
  781. // Registers Used:
  782. //
  783. //     AT, a3.
  784. //
  785. //--
  786.  
  787. #define INITIALIZE_PAL  call_pal initpal
  788.  
  789. //++
  790. //
  791. // WRITE_KERNEL_ENTRY_POINT
  792. //
  793. // Macro Description:
  794. //
  795. //     Register the kernel entry point to receive control for a
  796. //     class of exceptions.
  797. //
  798. // Mode:
  799. //
  800. //     Kernel only.
  801. //
  802. // Arguments:
  803. //
  804. //     a0 - Supplies the address of the kernel entry point.
  805. //     a1 - Supplies the class of exception dispatched to this entry point.
  806. //          0 = bug check conditions
  807. //          1 = memory management faults
  808. //          2 = interrupts
  809. //          3 = system service calls
  810. //          4 = general exception traps
  811. //
  812. // Return Value:
  813. //
  814. //     None.
  815. //
  816. // Registers Used:
  817. //
  818. //     AT, a2-a3.
  819. //
  820. //--
  821.  
  822. #define WRITE_KERNEL_ENTRY_POINT  call_pal wrentry
  823.  
  824. //
  825. // Define entry point values for the wrentry callpal function
  826. //
  827.  
  828. #define entryBugCheck   0
  829. #define entryMM         1
  830. #define entryInterrupt  2
  831. #define entrySyscall    3
  832. #define entryGeneral    4
  833.  
  834. //++
  835. //
  836. // CACHE_PCR_VALUES
  837. //
  838. // Macro Description:
  839. //
  840. //     Notify the PALcode that the PCR has been initialized by the
  841. //     kernel and the HAL and that the PALcode may now read values
  842. //     from the PCR and cache them inside the processor.
  843. //
  844. //     N.B. - the PCR pointer must have already been established in
  845. //          initpal
  846. //
  847. //     N.B. - This interface is a processor-specific implementation
  848. //          and cannot be assumed to be present on all processors.
  849. //          Currently implemented for the following processors:
  850. //
  851. //              DECchip 21064
  852. //
  853. // Mode:
  854. //
  855. //     Kernel only.
  856. //
  857. // Arguments:
  858. //
  859. //     None.
  860. //
  861. // Return Value:
  862. //
  863. //     None.
  864. //
  865. // Registers Used:
  866. //
  867. //     AT, a0 - a3.
  868. //
  869. //--
  870.  
  871. #define CACHE_PCR_VALUES  call_pal initpcr
  872.  
  873. //
  874. // Define transition interfaces
  875. //
  876.  
  877. //++
  878. //
  879. // RETURN_FROM_TRAP_OR_INTERRUPT
  880. //
  881. // Macro Description:
  882. //
  883. //     Return to execution thread after processing a trap or
  884. //     interrupt.  Traps can be general exceptions (breakpoint,
  885. //     arithmetic traps, etc.) or memory management faults.
  886. //     This macro is also used to startup a thread of execution
  887. //     for the first time.
  888. //
  889. // Mode:
  890. //
  891. //     Kernel only.
  892. //
  893. // Arguments:
  894. //
  895. //     a0 - Supplies the previous processor status register.
  896. //     a1 - Supplies new software interrupt requests.
  897. //          a1<1> - Request a DISPATCH Interrupt.
  898. //          a1<0> - Request an APC Interrupt.
  899. //
  900. // Return Value:
  901. //
  902. //     Does not return.
  903. //
  904. // Registers Used:
  905. //
  906. //     None.
  907. //
  908. //--
  909.  
  910. #define RETURN_FROM_TRAP_OR_INTERRUPT      call_pal rfe
  911.  
  912. //++
  913. //
  914. // RETURN_FROM_SYSTEM_CALL
  915. //
  916. // Macro Description:
  917. //
  918. //     Return from a system service call.
  919. //
  920. // Mode:
  921. //
  922. //     Kernel only.
  923. //
  924. // Arguments:
  925. //
  926. //     a0 - Supplies the previous processor status register.
  927. //     a1 - Supplies new software interrupt requests.
  928. //          a1<1> - Request a DISPATCH Interrupt.
  929. //          a1<0> - Request an APC Interrupt.
  930. //
  931. // Return Value:
  932. //
  933. //     Does not return.
  934. //
  935. // Registers Used:
  936. //
  937. //     All volatile registers.
  938. //
  939. //--
  940.  
  941. #define RETURN_FROM_SYSTEM_CALL   call_pal retsys
  942.  
  943. //++
  944. //
  945. // SYSCALL
  946. //
  947. // Macro Description:
  948. //
  949. //     Call a system service.
  950. //
  951. // Mode:
  952. //
  953. //     Kernel and User.
  954. //
  955. // Arguments:
  956. //
  957. //     v0 - Supplies the system service number.
  958. //     [other arguments as per calling standard]
  959. //
  960. // Return Value:
  961. //
  962. //     Will not return directly, returns via retsys, no return value.
  963. //
  964. // Registers Used:
  965. //
  966. //     All volatile registers.
  967. //
  968. //--
  969.  
  970. #define SYSCALL  call_pal callsys
  971.  
  972. //
  973. // Define breakpoint interfaces
  974. //
  975.  
  976. //++
  977. //
  978. // BREAK
  979. //
  980. // Macro Description:
  981. //
  982. //     Issue a user breakpoint which may be handled by a user-mode
  983. //     debugger.
  984. //
  985. // Mode:
  986. //
  987. //     Kernel and User.
  988. //
  989. // Arguments:
  990. //
  991. //     None.
  992. //
  993. // Return Value:
  994. //
  995. //     Will not return directly, returns via rti, no return value.
  996. //
  997. // Registers Used:
  998. //
  999. //     None.
  1000. //
  1001. //--
  1002.  
  1003. #define BREAK    call_pal bpt
  1004.  
  1005. //++
  1006. //
  1007. // BREAK_DEBUG_STOP
  1008. //
  1009. // Macro Description:
  1010. //
  1011. //     Issue a stop breakpoint to the kernel debugger.
  1012. //
  1013. // Mode:
  1014. //
  1015. //     Kernel and User.
  1016. //
  1017. // Arguments:
  1018. //
  1019. //     None.
  1020. //
  1021. // Return Value:
  1022. //
  1023. //     Will not return directly, returns via rti, no return value.
  1024. //
  1025. // Registers Used:
  1026. //
  1027. //     AT, v0.
  1028. //
  1029. //--
  1030.  
  1031. #define BREAK_DEBUG_STOP \
  1032.     ldil    v0, DEBUG_STOP_BREAKPOINT; \
  1033.     call_pal callkd
  1034.  
  1035. //++
  1036. //++
  1037. //
  1038. // BREAK_BREAKIN
  1039. //
  1040. // Macro Description:
  1041. //
  1042. //     Issue a breakin breakpoint to the kernel debugger.
  1043. //
  1044. // Mode:
  1045. //
  1046. //     Kernel and User.
  1047. //
  1048. // Arguments:
  1049. //
  1050. //     None.
  1051. //
  1052. // Return Value:
  1053. //
  1054. //     Will not return directly, returns via rti, no return value.
  1055. //
  1056. // Registers Used:
  1057. //
  1058. //     AT, v0.
  1059. //
  1060. //--
  1061.  
  1062. #define BREAK_BREAKIN \
  1063.     ldil    v0, BREAKIN_BREAKPOINT; \
  1064.     call_pal callkd
  1065.  
  1066. //++
  1067. //
  1068. // BREAK_DEBUG_LOAD_SYMBOLS
  1069. //
  1070. // Macro Description:
  1071. //
  1072. //     Issue a load symbols breakpoint to the kernel debugger.
  1073. //
  1074. // Mode:
  1075. //
  1076. //     Kernel and User.
  1077. //
  1078. // Arguments:
  1079. //
  1080. //     None.
  1081. //
  1082. // Return Value:
  1083. //
  1084. //     Will not return directly, returns via rti, no return value.
  1085. //
  1086. // Registers Used:
  1087. //
  1088. //     AT, v0.
  1089. //
  1090. //--
  1091.  
  1092. #define BREAK_DEBUG_LOAD_SYMBOLS \
  1093.     ldil    v0, DEBUG_LOAD_SYMBOLS_BREAKPOINT; \
  1094.     call_pal callkd
  1095.  
  1096. //++
  1097. //
  1098. // BREAK_DEBUG_UNLOAD_SYMBOLS
  1099. //
  1100. // Macro Description:
  1101. //
  1102. //     Issue a unload symbols breakpoint to the kernel debugger.
  1103. //
  1104. // Mode:
  1105. //
  1106. //     Kernel and User.
  1107. //
  1108. // Arguments:
  1109. //
  1110. //     None.
  1111. //
  1112. // Return Value:
  1113. //
  1114. //     Will not return directly, returns via rti, no return value.
  1115. //
  1116. // Registers Used:
  1117. //
  1118. //     AT, v0.
  1119. //
  1120. //--
  1121.  
  1122. #define BREAK_DEBUG_UNLOAD_SYMBOLS \
  1123.     ldil    v0, DEBUG_UNLOAD_SYMBOLS_BREAKPOINT; \
  1124.     call_pal callkd
  1125.  
  1126. //++
  1127. //
  1128. // BREAK_DEBUG_PRINT
  1129. //
  1130. // Macro Description:
  1131. //
  1132. //     Cause a debug print breakpoint which will be interpreted by
  1133. //     the kernel debugger and will print a string to the kernel debugger
  1134. //     port.
  1135. //
  1136. // Mode:
  1137. //
  1138. //     Kernel and User.
  1139. //
  1140. // Arguments:
  1141. //
  1142. //     a0 - Supplies the address of ASCII string to print.
  1143. //     a1 - Supplies the length of the string to print.
  1144. //
  1145. // Return Value:
  1146. //
  1147. //     Does not return directly, returns via rti, no return value.
  1148. //
  1149. // Registers Used:
  1150. //
  1151. //     AT, v0.
  1152. //
  1153. //--
  1154.  
  1155.  
  1156. #define BREAK_DEBUG_PRINT \
  1157.     ldil    v0, DEBUG_PRINT_BREAKPOINT; \
  1158.     call_pal callkd
  1159.  
  1160. //++
  1161. //
  1162. // BREAK_DEBUG_PROMPT
  1163. //
  1164. // Macro Description:
  1165. //
  1166. //     Cause a debug print breakpoint which will be interpreted by
  1167. //     the kernel debugger and will receive a string from the kernel debugger
  1168. //     port after prompting for input.
  1169. //
  1170. // Mode:
  1171. //
  1172. //     Kernel and User.
  1173. //
  1174. // Arguments:
  1175. //
  1176. //     a0 - Supplies the address of ASCII string to print.
  1177. //     a1 - Supplies the length of the string to print.
  1178. //     a2 - Supplies the address of the buffer to receive the input string.
  1179. //     a3 - Supplies the maximum length of the input string.
  1180. //
  1181. // Return Value:
  1182. //
  1183. //     Does not return directly, returns via rti, no return value.
  1184. //
  1185. // Registers Used:
  1186. //
  1187. //     AT, v0.
  1188. //
  1189. //--
  1190.  
  1191.  
  1192. #define BREAK_DEBUG_PROMPT \
  1193.     ldil    v0, DEBUG_PROMPT_BREAKPOINT; \
  1194.     call_pal callkd
  1195.  
  1196. //
  1197. // Define tb manipulation interfaces
  1198. //
  1199.  
  1200. //++
  1201. //
  1202. // TB_INVALIDATE_ALL
  1203. //
  1204. // Macro Description:
  1205. //
  1206. //     Invalidate all cached virtual address translations for the current
  1207. //     processor that are not fixed.
  1208. //     Some translations may be fixed in hardware and/or software and
  1209. //     these are not invalidated (eg. super-pages).
  1210. //
  1211. // Mode:
  1212. //
  1213. //     Kernel only.
  1214. //
  1215. // Arguments:
  1216. //
  1217. //     None.
  1218. //
  1219. // Return Value:
  1220. //
  1221. //     None.
  1222. //
  1223. // Registers Used:
  1224. //
  1225. //     a0 - a3.
  1226. //
  1227. //--
  1228.  
  1229.  
  1230. #define TB_INVALIDATE_ALL   call_pal tbia
  1231.  
  1232. //++
  1233. //
  1234. // TB_INVALIDATE_SINGLE
  1235. //
  1236. // Macro Description:
  1237. //
  1238. //     Invalidate any cached virtual address translations for a single
  1239. //     virtual address.
  1240. //
  1241. //     Note - it is legal for an implementation to invalidate more
  1242. //     translations that the single one specified.
  1243. //
  1244. // Mode:
  1245. //
  1246. //     Kernel only.
  1247. //
  1248. // Arguments:
  1249. //
  1250. //     a0 - Supplies the Virtual Address of the translation to invalidate.
  1251. //
  1252. // Return Value:
  1253. //
  1254. //     None.
  1255. //
  1256. // Registers Used:
  1257. //
  1258. //     a1 - a3.
  1259. //
  1260. //--
  1261.  
  1262. #define TB_INVALIDATE_SINGLE   call_pal tbis
  1263.  
  1264. //++
  1265. //
  1266. // TB_INVALIDATE_MULTIPLE
  1267. //
  1268. // Macro Description:
  1269. //
  1270. //     Invalidate any cached virtual address translations for the specified
  1271. //     set of virtual addresses.
  1272. //
  1273. //     Note - it is legal for an implementation to invalidate more
  1274. //     translations than those specified.
  1275. //
  1276. // Mode:
  1277. //
  1278. //     Kernel only.
  1279. //
  1280. // Arguments:
  1281. //
  1282. //     a0 - Supplies a pointer to the list of Virtual Addresses of the
  1283. //          translations to invalidate.
  1284. //     a1 - Supplies the count of Virtual Addresses in the list
  1285. //
  1286. // Return Value:
  1287. //
  1288. //     None.
  1289. //
  1290. // Registers Used:
  1291. //
  1292. //     a2.
  1293. //
  1294. //--
  1295.  
  1296. #define TB_INVALIDATE_MULTIPLE   call_pal tbim
  1297.  
  1298. //++
  1299. //
  1300. // TB_INVALIDATE_SINGLE_ASN
  1301. //
  1302. // Macro Description:
  1303. //
  1304. //     Invalidate any cached virtual address translations for a single
  1305. //     virtual address for the specified address space number.
  1306. //
  1307. //     Note - it is legal for an implementation to invalidate more
  1308. //     translations that the single one specified.
  1309. //
  1310. // Mode:
  1311. //
  1312. //     Kernel only.
  1313. //
  1314. // Arguments:
  1315. //
  1316. //     a0 - Supplies the Virtual Address of the translation to invalidate.
  1317. //
  1318. //     a1 - Supplies the Address Space Number of the translation to be
  1319. //          invalidated.
  1320. //
  1321. // Return Value:
  1322. //
  1323. //     None.
  1324. //
  1325. // Registers Used:
  1326. //
  1327. //     a1 - a3.
  1328. //
  1329. //--
  1330.  
  1331. #define TB_INVALIDATE_SINGLE_ASN   call_pal tbisasn
  1332.  
  1333. //++
  1334. //
  1335. // TB_INVALIDATE_MULTIPLE_ASN
  1336. //
  1337. // Macro Description:
  1338. //
  1339. //     Invalidate any cached virtual address translations for the specified
  1340. //     set of virtual addresses for the specified address space number.
  1341. //
  1342. //     Note - it is legal for an implementation to invalidate more
  1343. //     translations than those specified.
  1344. //
  1345. // Mode:
  1346. //
  1347. //     Kernel only.
  1348. //
  1349. // Arguments:
  1350. //
  1351. //     a0 - Supplies a pointer to the list of Virtual Addresses of the
  1352. //          translations to invalidate.
  1353. //
  1354. //     a1 - Supplies the count of Virtual Addresses in the list
  1355. //
  1356. //     a2 - Supplies the Address Space Number of the translation to be
  1357. //          invalidated.
  1358. //
  1359. // Return Value:
  1360. //
  1361. //     None.
  1362. //
  1363. // Registers Used:
  1364. //
  1365. //     a3.
  1366. //
  1367. //--
  1368.  
  1369. #define TB_INVALIDATE_MULTIPLE_ASN   call_pal tbimasn
  1370.  
  1371. //++
  1372. //
  1373. // DATA_TB_INVALIDATE_SINGLE
  1374. //
  1375. // Macro Description:
  1376. //
  1377. //     Invalidate data stream translations for a single virtual address.
  1378. //
  1379. //     Note - it is legal for an implementation to invalidate more
  1380. //     translations that the single one specified.
  1381. //
  1382. // Mode:
  1383. //
  1384. //     Kernel only.
  1385. //
  1386. // Arguments:
  1387. //
  1388. //     a0 - Supplies the Virtual Address of the translation to invalidate.
  1389. //
  1390. // Return Value:
  1391. //
  1392. //     None.
  1393. //
  1394. // Registers Used:
  1395. //
  1396. //     a1 - a3.
  1397. //
  1398. //--
  1399.  
  1400. #define DATA_TB_INVALIDATE_SINGLE  call_pal dtbis
  1401.  
  1402. //
  1403. // Define context switch interfaces
  1404. //
  1405.  
  1406. //++
  1407. //
  1408. // SWAP_THREAD_CONTEXT
  1409. //
  1410. // Macro Description:
  1411. //
  1412. //
  1413. //     Change to a new thread context.  This will mean a new kernel stack,
  1414. //     new current thread address and a new thread environment block.
  1415. //
  1416. // Mode:
  1417. //
  1418. //     Kernel only.
  1419. //
  1420. // Arguments:
  1421. //
  1422. //     a0 - Supplies the Virtual Address of new initial kernel stack.
  1423. //     a1 - Supplies the address of new thread object.
  1424. //     a2 - Supplies the address of new thread environment block.
  1425. //     a3 - Supplies the PFN of the new page directory if the process
  1426. //          is to be swapped, -1 otherwise.
  1427. //     a4 - Supplies the ASN of the new processor if the process is to
  1428. //          be swapped, undefined otherwise.
  1429. //     a5 - Supplies the ASN wrap indicator if the process is to be swapped,
  1430. //          undefined otherwise.
  1431. //
  1432. // Return Value:
  1433. //
  1434. //     None.
  1435. //
  1436. // Registers Used:
  1437. //
  1438. //     AT.
  1439. //
  1440. //--
  1441.  
  1442. #define SWAP_THREAD_CONTEXT   call_pal  swpctx
  1443.  
  1444. //++
  1445. //
  1446. // SWAP_PROCESS_CONTEXT
  1447. //
  1448. // Macro Description:
  1449. //
  1450. //     Change from one process address space to another.
  1451. //
  1452. // Mode:
  1453. //
  1454. //     Kernel only.
  1455. //
  1456. // Arguments:
  1457. //
  1458. //     a0 - Supplies the Pfn of Page Directory for new address space.
  1459. //     a1 - Supplies the Address Space Number for new address space.
  1460. //     a2 - Supplies the ASN wrap indicator (0 = no wrap, non-zero = wrap).
  1461. //
  1462. // Return Value:
  1463. //
  1464. //     None.
  1465. //
  1466. // Registers Used:
  1467. //
  1468. //     AT, a3.
  1469. //
  1470. //--
  1471.  
  1472. #define SWAP_PROCESS_CONTEXT  call_pal  swpprocess
  1473.  
  1474. //
  1475. // Define access to DPC Active flag
  1476. //
  1477.  
  1478. //++
  1479. //
  1480. // GET_DPC_ACTIVE_FLAG
  1481. //
  1482. // Macro Description:
  1483. //
  1484. //     Return the DPC Active Flag for the current processor.
  1485. //
  1486. // Mode:
  1487. //
  1488. //     Kernel only.
  1489. //
  1490. // Arguments:
  1491. //
  1492. //     None.
  1493. //
  1494. // Return Value:
  1495. //
  1496. //     v0 = DPC Active Flag
  1497. //
  1498. // Registers Used:
  1499. //
  1500. //     AT.
  1501. //
  1502. //--
  1503.  
  1504. #ifdef NT_UP
  1505.  
  1506. //
  1507. // The DPC Active flag can be safely acquired from the PCR (there is only one).
  1508. //
  1509.  
  1510. #define GET_DPC_ACTIVE_FLAG \
  1511.         GET_PROCESSOR_CONTROL_REGION_BASE; \
  1512.         ldl     v0, PcDpcRoutineActive(v0)
  1513.  
  1514. #else
  1515.  
  1516. //
  1517. // Ensure that the DPC flag fetch is atomic.
  1518. //
  1519.  
  1520. #define GET_DPC_ACTIVE_FLAG \
  1521.         DISABLE_INTERRUPTS;                 \
  1522.         GET_PROCESSOR_CONTROL_REGION_BASE;  \
  1523.         ldl     v0, PcDpcRoutineActive(v0); \
  1524.         ENABLE_INTERRUPTS;
  1525.  
  1526. #endif //NT_UP
  1527.  
  1528. //++
  1529. //
  1530. // SET_DPC_ACTIVE_FLAG
  1531. //
  1532. // Macro Description:
  1533. //
  1534. //     Set the DPC Active Flag for the current processor.
  1535. //
  1536. // Mode:
  1537. //
  1538. //     Kernel only.
  1539. //
  1540. // Arguments:
  1541. //
  1542. //     a0 = Supplies the DPC Active Flag Value to set.
  1543. //
  1544. // Return Value:
  1545. //
  1546. //     None.
  1547. //
  1548. // Registers Used:
  1549. //
  1550. //     AT.
  1551. //
  1552. //--
  1553.  
  1554. #define SET_DPC_ACTIVE_FLAG                     \
  1555.         .set    noat;                           \
  1556.         GET_PROCESSOR_CONTROL_REGION_BASE;      \
  1557.         stl     a0, PcDpcRoutineActive(v0);     \
  1558.         .set    at
  1559.  
  1560.  
  1561. //
  1562. // Define interfaces for generate trap
  1563. //
  1564.  
  1565. //++
  1566. //
  1567. // GENERATE_TRAP
  1568. //
  1569. // Macro Description:
  1570. //
  1571. //     Generate a trap.  Code has discovered an exception condition
  1572. //     and wants to raise a trap to indicate the condition.  Anticipated
  1573. //     for use by compilers for divide by zero, etc..
  1574. //
  1575. // Mode:
  1576. //
  1577. //     Kernel and User.
  1578. //
  1579. // Arguments:
  1580. //
  1581. //     a0 = Supplies the trap number which identifies the exception.
  1582. //
  1583. // Return Value:
  1584. //
  1585. //     Does not return, generates a trap to kernel mode, no return value.
  1586. //
  1587. // Registers Used:
  1588. //
  1589. //     None.
  1590. //
  1591. //--
  1592.  
  1593. #define GENERATE_TRAP call_pal gentrap
  1594.  
  1595. //
  1596. // Define performance and debug interfaces.
  1597. //
  1598.  
  1599. //++
  1600. //
  1601. // GET_INTERNAL_COUNTERS
  1602. //
  1603. // Macro Description:
  1604. //
  1605. //     Read the internal processor event counters.  The counter formats
  1606. //     and the events counted are processor implementation-dependent.
  1607. //
  1608. //     N.B. - the counters will only be implemented for checked builds.
  1609. //
  1610. // Mode:
  1611. //
  1612. //     Kernel.
  1613. //
  1614. // Arguments:
  1615. //
  1616. //     a0 - Supplies the superpage 32 address of the buffer to receive
  1617. //          the counter data.  The address must be quadword aligned.
  1618. //
  1619. //     a1 - Supplies the length of the buffer allocated for the counters.
  1620. //
  1621. // Return Value:
  1622. //
  1623. //     v0 - 0 is returned if the interface is not implemented.
  1624. //          If v0 <= a1 then v0 is the length of the data returned.
  1625. //          If v0 > a1 then v0 is the length of the processor implementation
  1626. //          counter record.
  1627. //
  1628. // Registers Used:
  1629. //
  1630. //     AT, a2 - a3.
  1631. //
  1632. //--
  1633.  
  1634. #define GET_INTERNAL_COUNTERS  call_pal rdcounters
  1635.  
  1636. //++
  1637. //
  1638. // GET_INTERNAL_PROCESSOR_STATE
  1639. //
  1640. // Macro Description:
  1641. //
  1642. //     Read the internal processor state.  The data values returned and
  1643. //     their format are processor implementation-dependent.
  1644. //
  1645. // Mode:
  1646. //
  1647. //     Kernel.
  1648. //
  1649. // Arguments:
  1650. //
  1651. //     a0 - Supplies the superpage 32 address of the buffer to receive
  1652. //          the processor state data.  The address must be quadword aligned.
  1653. //
  1654. //     a1 - Supplies the length of the buffer allocated for the state.
  1655. //
  1656. // Return Value:
  1657. //
  1658. //     v0 - If v0 <= a1 then v0 is the length of the data returned.
  1659. //          If v0 > a1 then v0 is the length of the processor implementation
  1660. //          state record.
  1661. //
  1662. // Registers Used:
  1663. //
  1664. //     AT, a2 - a3.
  1665. //
  1666. //--
  1667.  
  1668. #define GET_INTERNAL_PROCESSOR_STATE  call_pal rdstate
  1669.  
  1670. //++
  1671. //
  1672. // WRITE_PERFORMANCE_COUNTERS
  1673. //
  1674. // Macro Description:
  1675. //
  1676. //     Write the state of the internal processor performance counters.
  1677. //     The number of performance counters, the events they count, and their
  1678. //     usage is processor implementation-depedent.
  1679. //
  1680. // Mode:
  1681. //
  1682. //     Kernel.
  1683. //
  1684. // Arguments:
  1685. //
  1686. //     a0 - Supplies the number of the performance counter.
  1687. //
  1688. //     a1 - Supplies a flag that indicates if the performance counter is
  1689. //          to be enabled or disabled (0 = disabled, non-zero = enabled).
  1690. //
  1691. //     a2 - a5 - Supply processor implementation-dependent parameters.
  1692. //
  1693. // Return Value:
  1694. //
  1695. //     v0 - 0 is returned if the operation is unsuccessful or the performance
  1696. //          counter does not exist.  Otherwise, a non-zero value is returned.
  1697. //
  1698. // Registers Used:
  1699. //
  1700. //     AT, a2 - a5.
  1701. //
  1702. //--
  1703.  
  1704. #define WRITE_PERFORMANCE_COUNTERS  call_pal wrperfmon
  1705.  
  1706.  
  1707. //
  1708. // Define interfaces for controlling the state of machine checks.
  1709. //
  1710.  
  1711. //++
  1712. //
  1713. // DRAIN_ABORTS
  1714. //
  1715. // Macro Description:
  1716. //
  1717. //     Stall processor execution until all previous instructions have
  1718. //     executed to the point that any exceptions they may raise have been
  1719. //     signalled.
  1720. //
  1721. // Mode:
  1722. //
  1723. //     Kernel.
  1724. //
  1725. // Arguments:
  1726. //
  1727. //     None.
  1728. //
  1729. // Return Value:
  1730. //
  1731. //     None.
  1732. //
  1733. // Registers Used:
  1734. //
  1735. //     None.
  1736. //
  1737. //--
  1738.  
  1739. #define DRAIN_ABORTS  call_pal draina
  1740.  
  1741.  
  1742. //++
  1743. //
  1744. // GET_MACHINE_CHECK_ERROR_SUMMARY
  1745. //
  1746. // Macro Description:
  1747. //
  1748. //     Read the processor machine check error summary register.
  1749. //
  1750. // Mode:
  1751. //
  1752. //     Kernel.
  1753. //
  1754. // Arguments:
  1755. //
  1756. //     None.
  1757. //
  1758. // Return Value:
  1759. //
  1760. //     v0 - The value of the MCES register.
  1761. //
  1762. // Registers Used:
  1763. //
  1764. //     AT.
  1765. //
  1766. //--
  1767.  
  1768. #define GET_MACHINE_CHECK_ERROR_SUMMARY  call_pal rdmces
  1769.  
  1770.  
  1771. //++
  1772. //
  1773. // WRITE_MACHINE_CHECK_ERROR_SUMMARY
  1774. //
  1775. // Macro Description:
  1776. //
  1777. //     Write new values to the machine check error summary register.
  1778. //
  1779. // Mode:
  1780. //
  1781. //     Kernel.
  1782. //
  1783. // Arguments:
  1784. //
  1785. //     a0 - Supplies the values to write to the MCES register.
  1786. //
  1787. // Return Value:
  1788. //
  1789. //     v0 - Previous value of the MCES register.
  1790. //
  1791. // Registers Used:
  1792. //
  1793. //     AT, a1 - a3.
  1794. //
  1795. //--
  1796.  
  1797. #define WRITE_MACHINE_CHECK_ERROR_SUMMARY  call_pal wrmces
  1798.  
  1799.  
  1800. //++
  1801. //
  1802. // LoadByte(
  1803. //     Register Value,
  1804. //     Offset(Register) Base
  1805. //     )
  1806. //
  1807. // Macro Description:
  1808. //
  1809. //     Loades the byte at the base address defined by the
  1810. //     offset + register expression Base into the register Value
  1811. //
  1812. // Arguments:
  1813. //
  1814. //     Value - Supplies the string name of the destination register
  1815. //
  1816. //     Base - Supplies the base address (as an offset(register) string) of
  1817. //            the source of the byte.
  1818. //
  1819. // Return Value:
  1820. //
  1821. //     None.
  1822. //
  1823. // Registers Used:
  1824. //
  1825. //     AT
  1826. //
  1827. //--
  1828.  
  1829. #define LoadByte( Value, Base )        \
  1830.         .set    noat;                  \
  1831.         lda     AT, Base;              \
  1832.         ldq_u   Value, Base;           \
  1833.         extbl   Value, AT, Value;      \
  1834.         .set    at;
  1835.  
  1836.  
  1837. //++
  1838. //
  1839. // StoreByte(
  1840. //     Register Value,
  1841. //     Offset(Register) Base
  1842. //     )
  1843. //
  1844. // Macro Description:
  1845. //
  1846. //     Store the low byte of the register Value at the base address
  1847. //     defined by the offset + register expression Base.
  1848. //
  1849. //     N.B. - This macro preserves longword granularity of accesses.
  1850. //
  1851. // Arguments:
  1852. //
  1853. //     Value - Supplies the string name of the register containing the store
  1854. //             data.
  1855. //
  1856. //     Base - Supplies the base address (as an offset(register) string) of
  1857. //            the destination of the store.
  1858. //
  1859. // Return Value:
  1860. //
  1861. //     None.
  1862. //
  1863. // Registers Used:
  1864. //
  1865. //     AT, t12.
  1866. //
  1867. //--
  1868.  
  1869. #define StoreByte( Value, Base )        \
  1870.         .set    noat;                   \
  1871.         lda     AT, Base;               \
  1872.         ldq_u   t12, (AT);              \
  1873.         mskbl   t12, AT, t12;           \
  1874.         insbl   Value, AT, AT;          \
  1875.         bis     t12, AT, t12;           \
  1876.         lda     AT, Base;               \
  1877.         bic     AT, 3, AT;              \
  1878.         extll   t12, AT, t12;           \
  1879.         stl     t12, 0(AT);             \
  1880.         .set    at;
  1881.  
  1882.  
  1883. //++
  1884. //
  1885. // ZeroByte(
  1886. //     Offset(Register) Base
  1887. //     )
  1888. //
  1889. // Macro Description:
  1890. //
  1891. //     Zeroes the byte at the address defined by the offset + register
  1892. //     expression Base.
  1893. //
  1894. //     N.B. - This macro preserves longword granularity of accesses.
  1895. //
  1896. // Arguments:
  1897. //
  1898. //     Base - Supplies the base address (as an offset(register) string) of
  1899. //            the destination of the store.
  1900. //
  1901. // Return Value:
  1902. //
  1903. //     None.
  1904. //
  1905. // Registers Used:
  1906. //
  1907. //     AT, t12.
  1908. //
  1909. //--
  1910.  
  1911. #define ZeroByte( Base )        \
  1912.         .set    noat;                   \
  1913.         lda     AT, Base;               \
  1914.         ldq_u   t12, (AT);              \
  1915.         mskbl   t12, AT, t12;           \
  1916.         bic     AT, 3, AT;              \
  1917.         extll   t12, AT, t12;           \
  1918.         stl     t12, (AT);              \
  1919.         .set    at;
  1920.  
  1921. //++
  1922. //
  1923. // StoreByteAligned(
  1924. //     Register Value,
  1925. //     Offset(Register) Base
  1926. //     )
  1927. //
  1928. // Macro Description:
  1929. //
  1930. //     Store the low byte of the register Value at the base address
  1931. //     defined by the offset + register expression Base.  This macro
  1932. //     is functionally equivalent to StoreByte, but it assumes that
  1933. //     Base is dword aligned and optimizes the generated code
  1934. //     based on the alignment of Offset.
  1935. //
  1936. //     N.B. - This macro preserves longword granularity of accesses.
  1937. //
  1938. // Arguments:
  1939. //
  1940. //     Value - Supplies the string name of the register containing the store
  1941. //             data.
  1942. //
  1943. //     Base - Supplies the base address (as an offset(register) string) of
  1944. //            the destination of the store.
  1945. //
  1946. // Return Value:
  1947. //
  1948. //     None.
  1949. //
  1950. // Registers Used:
  1951. //
  1952. //     AT, t12.
  1953. //
  1954. //--
  1955.  
  1956. #define StoreByteAligned( Value, Offset, Base )         \
  1957.     .set    noat;                                       \
  1958.     ldl     AT, Offset(Base);                           \
  1959.     mskbl   AT, 0, t12;                                 \
  1960.     bis     t12, Value, AT;                             \
  1961.     stl     AT, Offset(Base);                           \
  1962.     .set    at;
  1963.  
  1964.  
  1965. //++
  1966. //
  1967. // ClearByteAligned(
  1968. //     Offset,
  1969. //     Base
  1970. //     )
  1971. //
  1972. // Macro Description:
  1973. //
  1974. //     Clears the byte at the location defined by the offset + register
  1975. //     expression Base.  It assumes that Base is dword aligned and optimizes
  1976. //     the generated code based on the alignment of Offset.
  1977. //
  1978. //     N.B. - This macro preserves longword granularity of accesses.
  1979. //
  1980. // Arguments:
  1981. //
  1982. //     Offset - Supplies the offset of the destination of the store.
  1983. //
  1984. //     Base - Supplies the base address of the destination of the store.
  1985. //
  1986. // Return Value:
  1987. //
  1988. //     None.
  1989. //
  1990. // Registers Used:
  1991. //
  1992. //     AT, t12.
  1993. //
  1994. //--
  1995.  
  1996. #define ZeroByteAligned( Offset, Base )          \
  1997.     .set    noat;                                       \
  1998.     ldl     AT, Offset(Base);                           \
  1999.     mskbl   AT, 0, t12;                                 \
  2000.     stl     t12, Offset(Base);                          \
  2001.     .set    at;
  2002.  
  2003.  
  2004.  
  2005. //++
  2006. //
  2007. // StoreWord(
  2008. //     Register Value,
  2009. //     Offset(Register) Base
  2010. //     )
  2011. //
  2012. // Macro Description:
  2013. //
  2014. //     Store the word of the register Value at the word aligned base address
  2015. //     defined by the offset + register expression Base.
  2016. //
  2017. //     N.B. - This macro preserves longword granularity of accesses.
  2018. //
  2019. //     N.B. - The destination must be word-aligned.
  2020. //
  2021. // Arguments:
  2022. //
  2023. //     Value - Supplies the string name of the register containing the store
  2024. //             data.
  2025. //
  2026. //     Base - Supplies the base address (as an offset(register) string) of
  2027. //            the destination of the store.
  2028. //
  2029. // Return Value:
  2030. //
  2031. //     None.
  2032. //
  2033. // Registers Used:
  2034. //
  2035. //     AT, t12.
  2036. //
  2037. //--
  2038.  
  2039. #define StoreWord( Value, Base )        \
  2040.         .set    noat;                   \
  2041.         lda     AT, Base;               \
  2042.         ldq_u   t12, (AT);              \
  2043.         mskwl   t12, AT, t12;           \
  2044.         inswl   Value, AT, AT;          \
  2045.         bis     t12, AT, t12;           \
  2046.         lda     AT, Base;               \
  2047.         bic     AT, 3, AT;              \
  2048.         extll   t12, AT, t12;           \
  2049.         stl     t12, 0(AT);             \
  2050.         .set    at;
  2051.  
  2052. //
  2053. // Define subtitle macro
  2054. //
  2055.  
  2056. #define SBTTL(x)
  2057.  
  2058. //
  2059. // Define mnemonic for writing callpal in assembly language that will
  2060. // fit in the opcode field.
  2061. //
  2062.  
  2063. #define callpal call_pal
  2064.  
  2065. //
  2066. // Define exception data section and align.
  2067. //
  2068. // Nearly all source files that include this header file need the following
  2069. // few pseudo-ops and so, by default, they are placed once here rather than
  2070. // repeated in every source file.  If these pseudo-ops are not needed, then
  2071. // define HEADER_FILE prior to including this file.
  2072. //
  2073. // Also the PALCODE environment uses this include file but cannot use
  2074. // these definitions.
  2075. //
  2076.  
  2077. #if  !defined(HEADER_FILE) && !defined(PALCODE)
  2078.  
  2079.         .edata 0
  2080.         .align 2
  2081.         .text
  2082.  
  2083. #endif
  2084.  
  2085.  
  2086.