2020#ifndef _TILE_HV_H
2121#define _TILE_HV_H
2222
23- #ifdef __tile__
2423#include <arch/chip.h>
25- #else
26- /* HACK: Allow use by "tools/cpack/". */
27- #include "install/include/arch/chip.h"
28- #endif
24+
25+ #include <hv/pagesize.h>
2926
3027/* Linux builds want unsigned long constants, but assembler wants numbers */
3128#ifdef __ASSEMBLER__
3936#define __HV_SIZE_ONE 1UL
4037#endif
4138
42-
4339/** The log2 of the span of a level-1 page table, in bytes.
4440 */
4541#define HV_LOG2_L1_SPAN 32
4844 */
4945#define HV_L1_SPAN (__HV_SIZE_ONE << HV_LOG2_L1_SPAN)
5046
51- /** The log2 of the size of small pages, in bytes. This value should
52- * be verified at runtime by calling hv_sysconf(HV_SYSCONF_PAGE_SIZE_SMALL).
53- */
54- #define HV_LOG2_PAGE_SIZE_SMALL 16
55-
5647/** The size of small pages, in bytes. This value should be verified
5748 * at runtime by calling hv_sysconf(HV_SYSCONF_PAGE_SIZE_SMALL).
5849 */
5950#define HV_PAGE_SIZE_SMALL (__HV_SIZE_ONE << HV_LOG2_PAGE_SIZE_SMALL)
6051
61- /** The log2 of the size of large pages, in bytes. This value should be
62- * verified at runtime by calling hv_sysconf(HV_SYSCONF_PAGE_SIZE_LARGE).
63- */
64- #define HV_LOG2_PAGE_SIZE_LARGE 24
65-
6652/** The size of large pages, in bytes. This value should be verified
6753 * at runtime by calling hv_sysconf(HV_SYSCONF_PAGE_SIZE_LARGE).
6854 */
9379#define HV_DISPATCH_ENTRY_SIZE 32
9480
9581/** Version of the hypervisor interface defined by this file */
96- #define _HV_VERSION 10
82+ #define _HV_VERSION 11
9783
9884/* Index into hypervisor interface dispatch code blocks.
9985 *
253239/** hv_set_command_line */
254240#define HV_DISPATCH_SET_COMMAND_LINE 47
255241
256- /** hv_dev_register_intr_state */
257- #define HV_DISPATCH_DEV_REGISTER_INTR_STATE 48
242+ #if !CHIP_HAS_IPI ()
243+
244+ /** hv_clear_intr */
245+ #define HV_DISPATCH_CLEAR_INTR 48
258246
259247/** hv_enable_intr */
260248#define HV_DISPATCH_ENABLE_INTR 49
261249
262250/** hv_disable_intr */
263251#define HV_DISPATCH_DISABLE_INTR 50
264252
253+ /** hv_raise_intr */
254+ #define HV_DISPATCH_RAISE_INTR 51
255+
265256/** hv_trigger_ipi */
266- #define HV_DISPATCH_TRIGGER_IPI 51
257+ #define HV_DISPATCH_TRIGGER_IPI 52
258+
259+ #endif /* !CHIP_HAS_IPI() */
267260
268261/** hv_store_mapping */
269- #define HV_DISPATCH_STORE_MAPPING 52
262+ #define HV_DISPATCH_STORE_MAPPING 53
270263
271264/** hv_inquire_realpa */
272- #define HV_DISPATCH_INQUIRE_REALPA 53
265+ #define HV_DISPATCH_INQUIRE_REALPA 54
273266
274267/** hv_flush_all */
275- #define HV_DISPATCH_FLUSH_ALL 54
268+ #define HV_DISPATCH_FLUSH_ALL 55
269+
270+ #if CHIP_HAS_IPI ()
271+ /** hv_get_ipi_pte */
272+ #define HV_DISPATCH_GET_IPI_PTE 56
273+ #endif
276274
277275/** One more than the largest dispatch value */
278- #define _HV_DISPATCH_END 55
276+ #define _HV_DISPATCH_END 57
279277
280278
281279#ifndef __ASSEMBLER__
@@ -484,21 +482,6 @@ typedef enum {
484482 */
485483int hv_confstr (HV_ConfstrQuery query , HV_VirtAddr buf , int len );
486484
487- /** State object used to enable and disable one-shot and level-sensitive
488- * interrupts. */
489- typedef struct
490- {
491- #if CHIP_VA_WIDTH () > 32
492- __hv64 opaque [2 ]; /**< No user-serviceable parts inside */
493- #else
494- __hv32 opaque [2 ]; /**< No user-serviceable parts inside */
495- #endif
496- }
497- HV_IntrState ;
498-
499- /** A set of interrupts. */
500- typedef __hv32 HV_IntrMask ;
501-
502485/** Tile coordinate */
503486typedef struct
504487{
@@ -509,34 +492,51 @@ typedef struct
509492 int y ;
510493} HV_Coord ;
511494
495+
496+ #if CHIP_HAS_IPI ()
497+
498+ /** Get the PTE for sending an IPI to a particular tile.
499+ *
500+ * @param tile Tile which will receive the IPI.
501+ * @param pl Indicates which IPI registers: 0 = IPI_0, 1 = IPI_1.
502+ * @param pte Filled with resulting PTE.
503+ * @result Zero if no error, non-zero for invalid parameters.
504+ */
505+ int hv_get_ipi_pte (HV_Coord tile , int pl , HV_PTE * pte );
506+
507+ #else /* !CHIP_HAS_IPI() */
508+
509+ /** A set of interrupts. */
510+ typedef __hv32 HV_IntrMask ;
511+
512512/** The low interrupt numbers are reserved for use by the client in
513513 * delivering IPIs. Any interrupt numbers higher than this value are
514514 * reserved for use by HV device drivers. */
515515#define HV_MAX_IPI_INTERRUPT 7
516516
517- /** Register an interrupt state object. This object is used to enable and
518- * disable one-shot and level-sensitive interrupts. Once the state is
519- * registered, the client must not read or write the state object; doing
520- * so will cause undefined results.
517+ /** Enable a set of device interrupts.
521518 *
522- * @param intr_state Pointer to interrupt state object.
523- * @return HV_OK on success, or a hypervisor error code.
519+ * @param enab_mask Bitmap of interrupts to enable.
524520 */
525- HV_Errno hv_dev_register_intr_state ( HV_IntrState * intr_state );
521+ void hv_enable_intr ( HV_IntrMask enab_mask );
526522
527- /** Enable a set of one-shot and level-sensitive interrupts.
523+ /** Disable a set of device interrupts.
528524 *
529- * @param intr_state Pointer to interrupt state object.
530- * @param enab_mask Bitmap of interrupts to enable.
525+ * @param disab_mask Bitmap of interrupts to disable.
531526 */
532- void hv_enable_intr ( HV_IntrState * intr_state , HV_IntrMask enab_mask );
527+ void hv_disable_intr ( HV_IntrMask disab_mask );
533528
534- /** Disable a set of one-shot and level-sensitive interrupts.
529+ /** Clear a set of device interrupts.
535530 *
536- * @param intr_state Pointer to interrupt state object.
537- * @param disab_mask Bitmap of interrupts to disable.
531+ * @param clear_mask Bitmap of interrupts to clear.
538532 */
539- void hv_disable_intr (HV_IntrState * intr_state , HV_IntrMask disab_mask );
533+ void hv_clear_intr (HV_IntrMask clear_mask );
534+
535+ /** Assert a set of device interrupts.
536+ *
537+ * @param assert_mask Bitmap of interrupts to clear.
538+ */
539+ void hv_assert_intr (HV_IntrMask assert_mask );
540540
541541/** Trigger a one-shot interrupt on some tile
542542 *
@@ -547,6 +547,8 @@ void hv_disable_intr(HV_IntrState* intr_state, HV_IntrMask disab_mask);
547547 */
548548HV_Errno hv_trigger_ipi (HV_Coord tile , int interrupt );
549549
550+ #endif // !CHIP_HAS_IPI()
551+
550552/** Store memory mapping in debug memory so that external debugger can read it.
551553 * A maximum of 16 entries can be stored.
552554 *
@@ -1010,6 +1012,13 @@ int hv_console_write(HV_VirtAddr bytes, int len);
10101012 * it will return to the code which was interrupted by the INTCTRL_1
10111013 * interrupt.
10121014 *
1015+ * Under some circumstances, the firing of INTCTRL_1 can race with
1016+ * the lowering of a device interrupt. In such a case, the
1017+ * hv_downcall_dispatch service may issue an iret instruction instead
1018+ * of entering one of the client's actual downcall-handling interrupt
1019+ * vectors. This will return execution to the location that was
1020+ * interrupted by INTCTRL_1.
1021+ *
10131022 * Any saving of registers should be done by the actual handling
10141023 * vectors; no registers should be changed by the INTCTRL_1 handler.
10151024 * In particular, the client should not use a jal instruction to invoke
0 commit comments