Files
nvdriver/tests/device-software/fixture.c
nvidia-driver-rs 4526e6a816 Baseline: validated 30/30 tree with passing Level 7 hardware regression
- Updated tools/post_reboot.sh to check kernel oops taint bit and stuck driver tasks instead of <86400s uptime
- Level 7 hardware regression passed on 0000:b3:00.0 (module 37e6fa430835eee2b426019db3ad70eeb7a9e9070c09c84bd9b973cf56cbe529, 107 inventory words, 0 static mismatches, CUDA baseline verified before and after)
- Updated .gitignore to exclude build archives (*.a, *.rlib), __pycache__, and raw trace dumps
2026-11-23 23:48:38 +00:00

57 lines
2.6 KiB
C

#define nv_rs_clock_store_alloc foundation_cpu_alloc
#define nv_rs_clock_store_free foundation_cpu_free
#define nv_rs_clock_store_process_context foundation_process_context
#define nv_rs_pci_read32 foundation_read32
#include "../dma-mock/ffi.c"
#undef nv_rs_pci_read32
#undef nv_rs_clock_store_alloc
#undef nv_rs_clock_store_free
#undef nv_rs_clock_store_process_context
extern _Thread_local bool fixture_process;
static unsigned alloc_at,alloc_calls,free_at,free_calls;
void fixture_cpu_alloc_at(unsigned n){alloc_at=n;alloc_calls=0;}
void fixture_cpu_free_at(unsigned n){free_at=n;free_calls=0;}
unsigned fixture_cpu_alloc_calls(void){return alloc_calls;}
bool nv_rs_clock_store_process_context(void){return fixture_process;}
void *nv_rs_clock_store_alloc(size_t bytes)
{alloc_calls++;if(alloc_at&&alloc_calls==alloc_at)return NULL;return foundation_cpu_alloc(bytes);}
int nv_rs_clock_store_free(void *p)
{free_calls++;if(free_at&&free_calls==free_at)return -EAGAIN;return foundation_cpu_free(p);}
int nv_rs_pci_bar0_info(struct nv_rs_pci *p,u64 *mapped,u64 *physical,u64 *bytes)
{if(!p||p->removed)return -ENODEV;*mapped=(uintptr_t)p;*physical=0x80000000ULL;*bytes=0x1000000;return 0;}
void *fixture_operation_create(void)
{pthread_mutex_t*p=malloc(sizeof(*p));pthread_mutexattr_t a;assert(p);assert(!pthread_mutexattr_init(&a));assert(!pthread_mutexattr_settype(&a,PTHREAD_MUTEX_ERRORCHECK));assert(!pthread_mutex_init(p,&a));assert(!pthread_mutexattr_destroy(&a));return p;}
int fixture_operation_lock(void*p){int e=pthread_mutex_lock(p);return e?-e:0;}
void fixture_operation_unlock(void*p){assert(!pthread_mutex_unlock(p));}
void fixture_operation_destroy(void*p){assert(!pthread_mutex_destroy(p));free(p);}
static u64 boot_trace[8];
static unsigned boot_reads, boot_fail_at;
static u32 boot4;
void fixture_boot_config(u32 value, unsigned fail_at)
{
boot4 = value;
boot_fail_at = fail_at;
boot_reads = 0;
}
unsigned fixture_boot_reads(void) { return boot_reads; }
u64 fixture_boot_offset(unsigned index) { assert(index < boot_reads && index < 8); return boot_trace[index]; }
int nv_rs_pci_read32(struct nv_rs_pci *pci, u64 offset, u32 *value)
{
if (pci->removed)
return -ENODEV;
if (offset != 0 && offset != 4 && offset != 0xa00 && offset != 0x8f020)
return foundation_read32(pci, offset, value);
boot_trace[boot_reads++ % 8] = offset;
if (boot_reads == boot_fail_at)
return -EIO;
switch (offset) {
case 0: *value = 0x140000a1; break;
case 4: *value = boot4; break;
case 0xa00: *value = 0x14000000; break;
default: *value = 0x1000; break;
}
return 0;
}