diff --git a/sys/arm64/arm64/gic_v3_its.c b/sys/arm64/arm64/gic_v3_its.c index 7d1c529469e0e4..c7287f5035e1f9 100644 --- a/sys/arm64/arm64/gic_v3_its.c +++ b/sys/arm64/arm64/gic_v3_its.c @@ -878,31 +878,31 @@ static __inline void cmd_format_command(struct its_cmd *cmd, uint8_t cmd_type) { /* Command field: DW0 [7:0] */ - cmd->cmd_dword[0] &= ~0xFFUL; - cmd->cmd_dword[0] |= cmd_type & 0xFF; + cmd->cmd_dword[0] &= ~CMD_COMMAND_MASK; + cmd->cmd_dword[0] |= cmd_type; } static __inline void cmd_format_devid(struct its_cmd *cmd, uint32_t devid) { /* Device ID field: DW0 [63:32] */ - cmd->cmd_dword[0] &= ~(0xFFFFFFFFUL << 32); - cmd->cmd_dword[0] |= ((uint64_t)devid << 32); + cmd->cmd_dword[0] &= ~CMD_DEVID_MASK; + cmd->cmd_dword[0] |= ((uint64_t)devid << CMD_DEVID_SHIFT); } static __inline void cmd_format_size(struct its_cmd *cmd, uint16_t size) { /* Size field: DW1 [4:0] */ - cmd->cmd_dword[1] &= ~0xFFUL; - cmd->cmd_dword[1] |= (size & 0xFF); + cmd->cmd_dword[1] &= ~CMD_SIZE_MASK; + cmd->cmd_dword[1] |= (size & CMD_SIZE_MASK); } static __inline void cmd_format_id(struct its_cmd *cmd, uint32_t id) { /* ID field: DW1 [31:0] */ - cmd->cmd_dword[1] &= ~0xFFFFFFFFUL; + cmd->cmd_dword[1] &= ~CMD_ID_MASK; cmd->cmd_dword[1] |= id; } @@ -910,15 +910,15 @@ static __inline void cmd_format_pid(struct its_cmd *cmd, uint32_t pid) { /* Physical ID field: DW1 [63:32] */ - cmd->cmd_dword[1] &= ~(0xFFFFFFFFUL << 32); - cmd->cmd_dword[1] |= ((uint64_t)pid << 32); + cmd->cmd_dword[1] &= ~CMD_PID_MASK; + cmd->cmd_dword[1] |= ((uint64_t)pid << CMD_PID_SHIFT); } static __inline void cmd_format_col(struct its_cmd *cmd, uint16_t col_id) { /* Collection field: DW2 [16:0] */ - cmd->cmd_dword[2] &= ~0xFFFFUL; + cmd->cmd_dword[2] &= ~CMD_COL_MASK; cmd->cmd_dword[2] |= col_id; } @@ -926,24 +926,24 @@ static __inline void cmd_format_target(struct its_cmd *cmd, uint64_t target) { /* Target Address field: DW2 [47:16] */ - cmd->cmd_dword[2] &= ~(0xFFFFFFFFUL << 16); - cmd->cmd_dword[2] |= (target & (0xFFFFFFFFUL << 16)); + cmd->cmd_dword[2] &= ~CMD_TARGET_MASK; + cmd->cmd_dword[2] |= (target & CMD_TARGET_MASK); } static __inline void cmd_format_itt(struct its_cmd *cmd, uint64_t itt) { /* ITT Address field: DW2 [47:8] */ - cmd->cmd_dword[2] &= ~0xFFFFFFFFFF00UL; - cmd->cmd_dword[2] |= (itt & 0xFFFFFFFFFF00UL); + cmd->cmd_dword[2] &= ~CMD_ITT_MASK; + cmd->cmd_dword[2] |= (itt & CMD_ITT_MASK); } static __inline void cmd_format_valid(struct its_cmd *cmd, uint8_t valid) { /* Valid field: DW2 [63] */ - cmd->cmd_dword[2] &= ~(1UL << 63); - cmd->cmd_dword[2] |= ((uint64_t)valid << 63); + cmd->cmd_dword[2] &= ~CMD_VALID_MASK; + cmd->cmd_dword[2] |= ((uint64_t)valid << CMD_VALID_SHIFT); } static __inline void diff --git a/sys/arm64/arm64/gic_v3_var.h b/sys/arm64/arm64/gic_v3_var.h index 2bde37d482ed40..b4c7fbbe49a66c 100644 --- a/sys/arm64/arm64/gic_v3_var.h +++ b/sys/arm64/arm64/gic_v3_var.h @@ -131,13 +131,36 @@ struct its_cmd { uint64_t cmd_dword[4]; /* ITS command double word */ }; -#define ITS_CMD_SYNC (0x05) -#define ITS_CMD_MAPD (0x08) -#define ITS_CMD_MAPC (0x09) -#define ITS_CMD_MAPVI (0x0a) -#define ITS_CMD_MAPI (0x0b) -#define ITS_CMD_INV (0x0c) -#define ITS_CMD_INVALL (0x0d) +/* ITS commands encoding */ +#define ITS_CMD_SYNC (0x05) +#define ITS_CMD_MAPD (0x08) +#define ITS_CMD_MAPC (0x09) +#define ITS_CMD_MAPVI (0x0a) +#define ITS_CMD_MAPI (0x0b) +#define ITS_CMD_INV (0x0c) +#define ITS_CMD_INVALL (0x0d) +/* Command */ +#define CMD_COMMAND_MASK (0xFFUL) +/* PCI device ID */ +#define CMD_DEVID_SHIFT (32) +#define CMD_DEVID_MASK (0xFFFFFFFFUL << CMD_DEVID_SHIFT) +/* Size of IRQ ID bitfield */ +#define CMD_SIZE_MASK (0xFFUL) +/* Virtual LPI ID */ +#define CMD_ID_MASK (0xFFFFFFFFUL) +/* Physical LPI ID */ +#define CMD_PID_SHIFT (32) +#define CMD_PID_MASK (0xFFFFFFFFUL << CMD_PID_SHIFT) +/* Collection */ +#define CMD_COL_MASK (0xFFFFUL) +/* Target (CPU or Re-Distributor) */ +#define CMD_TARGET_SHIFT (16) +#define CMD_TARGET_MASK (0xFFFFFFFFUL << CMD_TARGET_SHIFT) +/* Interrupt Translation Table address */ +#define CMD_ITT_MASK (0xFFFFFFFFFF00UL) +/* Valid command bit */ +#define CMD_VALID_SHIFT (63) +#define CMD_VALID_MASK (1UL << CMD_VALID_SHIFT) /* * ITS command descriptor.