Use a table to convert channel ids to PRV types

This commit is contained in:
Rodrigo Arias 2021-10-21 16:39:36 +02:00
parent 0f09a3a514
commit d6afd5c528
2 changed files with 51 additions and 24 deletions

66
emu.h
View File

@ -99,37 +99,63 @@ struct ovni_chan {
/* Where should the events be written to? */ /* Where should the events be written to? */
FILE *prv; FILE *prv;
/* What should cause the channel to become disabled? */
enum chan_track track;
}; };
enum chan { enum chan {
/* Ovni */
CHAN_OVNI_STATE = 0,
CHAN_OVNI_TID,
CHAN_OVNI_PID, CHAN_OVNI_PID,
CHAN_OVNI_TID,
CHAN_OVNI_NTHREADS,
CHAN_OVNI_STATE,
CHAN_OVNI_APPID,
CHAN_OVNI_CPU,
/* nOS-V */ CHAN_NOSV_TASKID,
CHAN_NOSV_TASK_ID, CHAN_NOSV_TYPEID,
CHAN_NOSV_SS, /* Subsystem */ CHAN_NOSV_APPID,
CHAN_NOSV_SUBSYSTEM,
CHAN_MAX CHAN_MAX
}; };
/* All PRV event types */ /* Same order as `enum chan` */
enum prv_type { static int chan_to_prvtype[CHAN_MAX][3] = {
/* Rows are CPUs */ /* Channel TH CPU */
PTC_PROC_PID = 10, { CHAN_OVNI_PID, 10, 60 },
PTC_THREAD_TID = 11, { CHAN_OVNI_TID, 11, 61 },
PTC_NTHREADS = 12, { CHAN_OVNI_NTHREADS, -1, 62 },
PTC_TASK_ID = 20, { CHAN_OVNI_STATE, 13, 63 },
PTC_TASK_TYPE_ID = 21, { CHAN_OVNI_APPID, 14, 64 },
PTC_APP_ID = 30, { CHAN_OVNI_CPU, 15, -1 },
PTC_SUBSYSTEM = 31,
/* Rows are threads */ { CHAN_NOSV_TASKID, 20, 70 },
PTT_THREAD_STATE = 60, { CHAN_NOSV_TYPEID, 21, 71 },
PTT_THREAD_TID = 61, { CHAN_NOSV_APPID, 22, 72 },
PTT_SUBSYSTEM = 62, { CHAN_NOSV_SUBSYSTEM, 23, 73 },
}; };
///* All PRV event types */
//enum prv_type {
// /* Rows are CPUs */
// PTC_PROC_PID = 10,
// PTC_THREAD_TID = 11,
// PTC_NTHREADS = 12,
// PTC_TASK_ID = 20,
// PTC_TASK_TYPE_ID = 21,
// PTC_APP_ID = 30,
// PTC_SUBSYSTEM = 31,
//
// /* Rows are threads */
// PTT_THREAD_STATE = 60,
// PTT_THREAD_TID = 61,
// PTT_SUBSYSTEM = 62,
//
// PTT_TASK_ID = 63,
// PTT_TASK_TYPE_ID = 64,
// PTT_TASK_APP_ID = 65,
//};
/* State of each emulated thread */ /* State of each emulated thread */
struct ovni_ethread { struct ovni_ethread {
/* Emulated thread tid */ /* Emulated thread tid */

9
pcf.c
View File

@ -98,8 +98,9 @@ struct event_value thread_state_values[] = {
{ -1, NULL }, { -1, NULL },
}; };
/* FIXME: Use enum */
struct event_type thread_state = { struct event_type thread_state = {
0, PTT_THREAD_STATE, "Thread: State", 0, 13, "Thread: State",
thread_state_values thread_state_values
}; };
@ -110,7 +111,7 @@ struct event_value thread_tid_values[] = {
}; };
struct event_type thread_tid = { struct event_type thread_tid = {
0, PTC_THREAD_TID, "CPU: Thread TID", 0, 61, "CPU: Thread TID",
thread_tid_values thread_tid_values
}; };
@ -128,12 +129,12 @@ struct event_value ss_values[] = {
}; };
struct event_type thread_ss = { struct event_type thread_ss = {
0, PTT_SUBSYSTEM, "Thread: Subsystem", 0, 23, "Thread: Subsystem",
ss_values ss_values
}; };
struct event_type cpu_ss = { struct event_type cpu_ss = {
0, PTC_SUBSYSTEM, "CPU: Current thread subsystem", 0, 73, "CPU: Current thread subsystem",
ss_values ss_values
}; };