Skip to content

Commit

Permalink
Introduce macro definitions for ITS commands formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
semihalf-bodek-zbigniew committed Mar 11, 2015
1 parent ec0f344 commit aa7f775
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
32 changes: 16 additions & 16 deletions sys/arm64/arm64/gic_v3_its.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,72 +878,72 @@ 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;
}

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;
}

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
Expand Down
37 changes: 30 additions & 7 deletions sys/arm64/arm64/gic_v3_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit aa7f775

Please sign in to comment.