omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / tests / rpc_ref.c
| 1 | /* Test-only oracle. Never linked into the Omega driver. Builds against pinned aienux C. */ |
| 2 | #include "gb10_gsp_boot.h" |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | #include <string.h> |
| 6 | static unsigned char cmd[GSP_MQ_QUEUE_SIZE], stat[GSP_MQ_QUEUE_SIZE]; |
| 7 | static void put(unsigned char *p, unsigned v) { for(unsigned i=0;i<4;i++)p[i]=(unsigned char)(v>>(8*i)); } |
| 8 | static void init(unsigned char *p) { |
| 9 | put(p+4,GSP_MQ_QUEUE_SIZE);put(p+8,GSP_MQ_MSG_SIZE);put(p+12,GSP_MQ_MSG_COUNT); |
| 10 | put(p+20,1);put(p+24,32);put(p+28,4096); |
| 11 | } |
| 12 | static void emit(void) { if(fwrite(cmd,1,sizeof cmd,stdout)!=sizeof cmd)exit(2); } |
| 13 | int main(void) { |
| 14 | gsp_mq q={cmd,stat,0,0,0}; const char *why=0; unsigned seq; |
| 15 | init(cmd); init(stat); |
| 16 | unsigned char payload[8192];for(unsigned i=0;i<sizeof payload;i++)payload[i]=(unsigned char)i; |
| 17 | gsp_seg s={payload,17}; |
| 18 | if(gsp_mq_send(&q,72,&s,1,17,0,&seq,&why))return 3; |
| 19 | emit(); |
| 20 | s.len=8192; |
| 21 | if(gsp_mq_send(&q,76,&s,1,8192,1,&seq,&why))return 4; |
| 22 | emit(); |
| 23 | /* Force a wrapped two-slot command, peer read pointer is in stat, not cmd. */ |
| 24 | put(cmd+16,62);put(stat+32,10);s.len=4020; |
| 25 | if(gsp_mq_send(&q,76,&s,1,4020,1,&seq,&why))return 5; |
| 26 | emit(); |
| 27 | /* Existing paroot encoder: match its independent NV0000_ALLOC_PARAMETERS fixture. */ |
| 28 | unsigned char root[120]={0};put(root,7);put(root+4,42);memcpy(root+8,"aien-ogd",8); |
| 29 | if(gsp_rpc_rm_alloc(&q,7,0,7,0,root,sizeof root,&seq,&why))return 6; |
| 30 | emit(); |
| 31 | return 0; |
| 32 | } |