TT Zephyr Platforms 18.11.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
msgqueue.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdatomic.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <tenstorrent/msgqueue.h>
#include <tenstorrent/smc_msg.h>
#include <tenstorrent/post_code.h>
#include <tenstorrent/sys_init_defines.h>
#include "status_reg.h"
#include "reg.h"
#include "irqnum.h"

Data Structures

struct  RESET_UNIT_ARC_MISC_CNTL_reg_t
union  RESET_UNIT_ARC_MISC_CNTL_reg_u
struct  MSI_CATCHER_STATUS_reg_t
union  MSI_CATCHER_STATUS_reg_u
struct  message_queue

Macros

#define MSGHANDLER_COMPAT_MASK   0x1
#define MSG_ERROR_REPLY   0xff
#define POST_CODE_REG_ADDR   0x0060
#define APB_BASE_ADDR   0x80000000
#define RESET_UNIT_OFFSET_ADDR   0x30000
#define RESET_UNIT_START_ADDR    ((volatile uint32_t *)(APB_BASE_ADDR + RESET_UNIT_OFFSET_ADDR))
#define RESET_UNIT_ARC_MISC_CNTL_REG_ADDR   0x80030100
#define RESET_UNIT_ARC_MISC_CNTL_REG_DEFAULT   (0x00000000)
#define MSI_CATCHER_BASE   (APB_BASE_ADDR + 0xB0000)
#define MSI_CATCHER_FIFO_OFFSET   0
#define MSI_CATCHER_FIFO_REG_ADDR   (MSI_CATCHER_BASE + MSI_CATCHER_FIFO_OFFSET)
#define MSI_CATCHER_FLUSH_OFFSET   4
#define MSI_CATCHER_FLUSH_REG_ADDR   (MSI_CATCHER_BASE + MSI_CATCHER_FLUSH_OFFSET)
#define MSI_CATCHER_STATUS_OFFSET   8
#define MSI_CATCHER_STATUS_REG_ADDR   (MSI_CATCHER_BASE + MSI_CATCHER_STATUS_OFFSET)

Functions

 BUILD_ASSERT (sizeof(union request)<=(sizeof(uint32_t) *REQUEST_MSG_LEN))
 __attribute__ ((used))
static void * mask_voidp (void *x, uintptr_t mask)
static void * unmask_voidp (void *x, uintptr_t mask)
static union requestrequest_entry (struct message_queue *queue, uint32_t ptr)
static struct responseresponse_entry (struct message_queue *queue, uint32_t ptr)
int msgqueue_request_push (uint32_t msgqueue_id, const union request *request)
int msgqueue_request_pop (uint32_t msgqueue_id, union request *request)
int msgqueue_response_push (uint32_t msgqueue_id, const struct response *response)
int msgqueue_response_pop (uint32_t msgqueue_id, struct response *response)
static bool start_next_message (struct message_queue *queue, uint32_t *request_rptr_out, uint32_t *response_wptr_out)
static bool command_writes_serial (const union request *request)
static void advance_serial (struct message_queue *queue, const union request *request)
static void process_l2_message_queue (const union request *request, struct response *response)
static void handle_set_last_serial (struct message_queue *queue, const union request *request)
static void handle_test (struct message_queue *queue, const union request *request, struct response *response)
static void report_scratch_only_message (struct response *response)
static void process_queued_message (struct message_queue *queue, const union request *request, struct response *response)
static void process_message_queue (struct message_queue *queue)
void clear_msg_irq (void)
void process_message_queues (void)
void msgqueue_register_handler (uint32_t msg_code, msgqueue_request_handler_t handler)
static void prepare_msg_queue (void)
static int register_interrupt_handlers (void)
 SYS_INIT_APP (register_interrupt_handlers)
void init_msgqueue (void)

Variables

static struct message_queue message_queues [NUM_MSG_QUEUES]
static void * message_handlers [CONFIG_TT_BH_ARC_NUM_MSG_CODES]

Macro Definition Documentation

◆ APB_BASE_ADDR

#define APB_BASE_ADDR   0x80000000

◆ MSG_ERROR_REPLY

#define MSG_ERROR_REPLY   0xff

◆ MSGHANDLER_COMPAT_MASK

#define MSGHANDLER_COMPAT_MASK   0x1

◆ MSI_CATCHER_BASE

#define MSI_CATCHER_BASE   (APB_BASE_ADDR + 0xB0000)

◆ MSI_CATCHER_FIFO_OFFSET

#define MSI_CATCHER_FIFO_OFFSET   0

◆ MSI_CATCHER_FIFO_REG_ADDR

#define MSI_CATCHER_FIFO_REG_ADDR   (MSI_CATCHER_BASE + MSI_CATCHER_FIFO_OFFSET)

◆ MSI_CATCHER_FLUSH_OFFSET

#define MSI_CATCHER_FLUSH_OFFSET   4

◆ MSI_CATCHER_FLUSH_REG_ADDR

#define MSI_CATCHER_FLUSH_REG_ADDR   (MSI_CATCHER_BASE + MSI_CATCHER_FLUSH_OFFSET)

◆ MSI_CATCHER_STATUS_OFFSET

#define MSI_CATCHER_STATUS_OFFSET   8

◆ MSI_CATCHER_STATUS_REG_ADDR

#define MSI_CATCHER_STATUS_REG_ADDR   (MSI_CATCHER_BASE + MSI_CATCHER_STATUS_OFFSET)

◆ POST_CODE_REG_ADDR

#define POST_CODE_REG_ADDR   0x0060

◆ RESET_UNIT_ARC_MISC_CNTL_REG_ADDR

#define RESET_UNIT_ARC_MISC_CNTL_REG_ADDR   0x80030100

◆ RESET_UNIT_ARC_MISC_CNTL_REG_DEFAULT

#define RESET_UNIT_ARC_MISC_CNTL_REG_DEFAULT   (0x00000000)

◆ RESET_UNIT_OFFSET_ADDR

#define RESET_UNIT_OFFSET_ADDR   0x30000

◆ RESET_UNIT_START_ADDR

#define RESET_UNIT_START_ADDR    ((volatile uint32_t *)(APB_BASE_ADDR + RESET_UNIT_OFFSET_ADDR))

Function Documentation

◆ __attribute__()

__attribute__ ( (used) )

◆ advance_serial()

void advance_serial ( struct message_queue * queue,
const union request * request )
static

◆ BUILD_ASSERT()

BUILD_ASSERT ( sizeof(union request)<=(sizeof(uint32_t) *REQUEST_MSG_LEN) )

◆ clear_msg_irq()

void clear_msg_irq ( void )

◆ command_writes_serial()

bool command_writes_serial ( const union request * request)
static

◆ handle_set_last_serial()

void handle_set_last_serial ( struct message_queue * queue,
const union request * request )
static

◆ handle_test()

void handle_test ( struct message_queue * queue,
const union request * request,
struct response * response )
static

◆ init_msgqueue()

void init_msgqueue ( void )

◆ mask_voidp()

void * mask_voidp ( void * x,
uintptr_t mask )
inlinestatic

◆ msgqueue_register_handler()

void msgqueue_register_handler ( uint32_t msg_code,
msgqueue_request_handler_t handler )

◆ msgqueue_request_pop()

int msgqueue_request_pop ( uint32_t msgqueue_id,
union request * request )

◆ msgqueue_request_push()

int msgqueue_request_push ( uint32_t msgqueue_id,
const union request * request )

◆ msgqueue_response_pop()

int msgqueue_response_pop ( uint32_t msgqueue_id,
struct response * response )

◆ msgqueue_response_push()

int msgqueue_response_push ( uint32_t msgqueue_id,
const struct response * response )

◆ prepare_msg_queue()

void prepare_msg_queue ( void )
static

◆ process_l2_message_queue()

void process_l2_message_queue ( const union request * request,
struct response * response )
static

◆ process_message_queue()

void process_message_queue ( struct message_queue * queue)
static

◆ process_message_queues()

void process_message_queues ( void )

◆ process_queued_message()

void process_queued_message ( struct message_queue * queue,
const union request * request,
struct response * response )
static

◆ register_interrupt_handlers()

int register_interrupt_handlers ( void )
static

◆ report_scratch_only_message()

void report_scratch_only_message ( struct response * response)
static

◆ request_entry()

union request * request_entry ( struct message_queue * queue,
uint32_t ptr )
static

◆ response_entry()

struct response * response_entry ( struct message_queue * queue,
uint32_t ptr )
static

◆ start_next_message()

bool start_next_message ( struct message_queue * queue,
uint32_t * request_rptr_out,
uint32_t * response_wptr_out )
static

◆ SYS_INIT_APP()

SYS_INIT_APP ( register_interrupt_handlers )

◆ unmask_voidp()

void * unmask_voidp ( void * x,
uintptr_t mask )
inlinestatic

Variable Documentation

◆ message_handlers

void* message_handlers[CONFIG_TT_BH_ARC_NUM_MSG_CODES]
static

◆ message_queues

struct message_queue message_queues[NUM_MSG_QUEUES]
static