Move to new logging system.

This commit is contained in:
starfrost013
2025-01-15 01:52:33 +00:00
parent 7393874d8e
commit 1c25e61896
3 changed files with 34 additions and 6 deletions

View File

@@ -27,7 +27,7 @@
#ifdef EMU_DEVICE_H // what
//TODO: split this all into nv1, nv3, nv4...
#include <86box/log.h>
#include <86box/i2c.h>
#include <86box/vid_ddc.h>
#include <86box/timer.h>
@@ -35,6 +35,7 @@
#include <86box/vid_svga_render.h>
#include <86box/nv/vid_nv_rivatimer.h>
void nv_log_set_device(void* device);
void nv_log(const char *fmt, ...);
// Defines common to all NV chip architectural generations
@@ -92,6 +93,7 @@ typedef struct nv_base_s
rom_t vbios; // NVIDIA/OEm VBIOS
// move to nv3_cio_t?
svga_t svga; // SVGA core (separate to nv3) - Weitek licensed
void* log; // new logging engine
// stuff that doesn't fit in the svga structure
uint32_t cio_read_bank; // SVGA read bank
uint32_t cio_write_bank; // SVGA write bank
@@ -114,7 +116,7 @@ typedef struct nv_base_s
rivatimer_t* memory_clock_timer; // Timer for measuring memory/gpu clock
bool memory_clock_enabled; // Memory Clock Enabled - stupid crap used to prevent us eanbling the timer multiple times
void* i2c; // I2C for monitor EDID
void* ddc;
void* ddc; // Display Data Channel for EDID
} nv_base_t;
#define NV_REG_LIST_END 0xD15EA5E

View File

@@ -913,6 +913,10 @@ void nv3_update_mappings()
//
void* nv3_init(const device_t *info)
{
nv3->nvbase.log = log_open("NV3");
// Allows nv_log to be used for multiple nvidia devices
nv_log_set_device(nv3->nvbase.log);
nv_log("NV3: initialising core\n");
// Figure out which vbios the user selected
@@ -928,9 +932,13 @@ void* nv3_init(const device_t *info)
int32_t err = rom_init(&nv3->nvbase.vbios, vbios_file, 0xC0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL);
if (err)
nv_log("NV3: failed to load VBIOS err=%d\n", err);
{
nv_log("NV3 FATAL: failed to load VBIOS err=%d\n", err);
fatal("Nvidia NV3 init failed: Somehow selected a nonexistent VBIOS? err=%d\n", err);
return NULL;
}
else
nv_log("NV3: Successfully loaded VBIOS %s located at %s\n", vbios_id, vbios_file);
nv_log("NV3: Successfully loaded VBIOS %s located at %s\n", vbios_id, vbios_file);
// set the vram amount and gpu revision
uint32_t vram_amount = device_get_config_int("VRAM");
@@ -1004,6 +1012,10 @@ void* nv3_init_agp(const device_t* info)
void nv3_close(void* priv)
{
// Shut down logging
log_close(nv3->nvbase.log);
nv_log_set_device(NULL);
// Shut down I2C and the DDC
ddc_close(nv3->nvbase.ddc);
i2c_gpio_close(nv3->nvbase.i2c);

View File

@@ -17,9 +17,11 @@
// Common NV1/3/4... init
#define HAVE_STDARG_H // wtf is this crap
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <86box/log.h>
#include <86box/86box.h>
#include <86box/nv/vid_nv.h>
@@ -28,13 +30,25 @@
#ifdef ENABLE_NV_LOG
int nv_do_log = ENABLE_NV_LOG;
// A bit of kludge so that in the future we can abstract this function acorss multiple generations of Nvidia GPUs
void* nv_log_device;
void nv_log_set_device(void* device)
{
nv_log_device = device;
}
void nv_log(const char *fmt, ...)
{
if (!nv_log_device)
return;
va_list ap;
if (nv_do_log) {
va_start(ap, fmt);
pclog_ex_cyclic(fmt, ap);
log_out_cyclic(nv_log_device, fmt, ap);
va_end(ap);
}
}