main: print pci vendor/device id
This commit is contained in:
parent
68fb5ba5fb
commit
b903bc3967
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,3 +12,4 @@ __pycache__
|
|||||||
*.cmd
|
*.cmd
|
||||||
*.order
|
*.order
|
||||||
*.mod.c
|
*.mod.c
|
||||||
|
*.out
|
20
dac.h
Normal file
20
dac.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#define DAC__RS__PIXEL_ADDRESS_WRITE 0b000
|
||||||
|
#define DAC__RS__PIXEL_ADDRESS_READ 0b011
|
||||||
|
#define DAC__RS__COLOR_VALUE 0b001
|
||||||
|
#define DAC__RS__PIXEL_MASK 0b010
|
||||||
|
#define DAC__RS__PLL_ADDRESS_WRITE 0b100
|
||||||
|
#define DAC__RS__PLL_PARAMETER 0b101
|
||||||
|
#define DAC__RS__COMMAND 0b110
|
||||||
|
#define DAC__RS__PLL_ADDRESS_READ 0b111
|
||||||
|
|
||||||
|
#define DAC__PLL_PARAMETER__CLK0_f0_PLL 0x00
|
||||||
|
#define DAC__PLL_PARAMETER__CLK0_f1_PLL 0x01
|
||||||
|
#define DAC__PLL_PARAMETER__CLK0_f2_PLL 0x02
|
||||||
|
#define DAC__PLL_PARAMETER__CLK0_f3_PLL 0x03
|
||||||
|
#define DAC__PLL_PARAMETER__CLK0_f4_PLL 0x04
|
||||||
|
#define DAC__PLL_PARAMETER__CLK0_f5_PLL 0x05
|
||||||
|
#define DAC__PLL_PARAMETER__CLK0_f6_PLL 0x06
|
||||||
|
#define DAC__PLL_PARAMETER__CLK0_f7_PLL 0x07
|
||||||
|
#define DAC__PLL_PARAMETER__CLK1_fA_PLL 0x0a
|
||||||
|
#define DAC__PLL_PARAMETER__CLK1_fB_PLL 0x0b
|
||||||
|
#define DAC__PLL_PARAMETER__PLL_CONTROL 0x0e
|
@ -205,6 +205,8 @@ def render_all(rls):
|
|||||||
yield ""
|
yield ""
|
||||||
yield from render_register_struct(rls, max_length)
|
yield from render_register_struct(rls, max_length)
|
||||||
yield from render_static_assert(rls, max_length)
|
yield from render_static_assert(rls, max_length)
|
||||||
|
yield ""
|
||||||
|
yield "typedef struct voodoo2_reg voodoo2_reg;"
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
with open(sys.argv[1], 'r') as f:
|
||||||
buf = f.read()
|
buf = f.read()
|
||||||
|
@ -83,6 +83,8 @@ def render_all(buf):
|
|||||||
yield '#include "reg.h"'
|
yield '#include "reg.h"'
|
||||||
yield ""
|
yield ""
|
||||||
yield from render_struct(buf)
|
yield from render_struct(buf)
|
||||||
|
yield ""
|
||||||
|
yield "typedef struct voodoo2_config voodoo2_config;"
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
with open(sys.argv[1], 'r') as f:
|
||||||
buf = f.read()
|
buf = f.read()
|
||||||
|
54
main.c
54
main.c
@ -8,6 +8,9 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "voodoo2.h"
|
#include "voodoo2.h"
|
||||||
|
#include "voodoo2_bits.h"
|
||||||
|
#include "voodoo2_config.h"
|
||||||
|
#include "dac.h"
|
||||||
|
|
||||||
struct name_int {
|
struct name_int {
|
||||||
const char * name;
|
const char * name;
|
||||||
@ -81,10 +84,10 @@ static inline void dac_write_pll_8(voodoo2_reg * voodoo2,
|
|||||||
int address,
|
int address,
|
||||||
int parameter_m)
|
int parameter_m)
|
||||||
{
|
{
|
||||||
dac_data_write(voodoo2, address, DAC__RS__PLL_ADDRESS_WRITE, 0);
|
dac_data_write(voodoo2, address, DAC__RS__PLL_ADDRESS_WRITE);
|
||||||
wait_graphics_busy(voodoo2);
|
wait_graphics_busy(voodoo2);
|
||||||
|
|
||||||
dac_data_write(voodoo2, parameter_m, DAC__RS__PLL_PARAMETER, 0);
|
dac_data_write(voodoo2, parameter_m, DAC__RS__PLL_PARAMETER);
|
||||||
wait_graphics_busy(voodoo2);
|
wait_graphics_busy(voodoo2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,13 +96,13 @@ static inline void dac_write_pll_16(voodoo2_reg * voodoo2,
|
|||||||
int parameter_m,
|
int parameter_m,
|
||||||
int parameter_n)
|
int parameter_n)
|
||||||
{
|
{
|
||||||
dac_data_write(voodoo2, address, DAC__RS__PLL_ADDRESS_WRITE, 0);
|
dac_data_write(voodoo2, address, DAC__RS__PLL_ADDRESS_WRITE);
|
||||||
wait_graphics_busy(voodoo2);
|
wait_graphics_busy(voodoo2);
|
||||||
|
|
||||||
dac_data_write(voodoo2, parameter_m, DAC__RS__PLL_PARAMETER, 0);
|
dac_data_write(voodoo2, parameter_m, DAC__RS__PLL_PARAMETER);
|
||||||
wait_graphics_busy(voodoo2);
|
wait_graphics_busy(voodoo2);
|
||||||
|
|
||||||
dac_data_write(voodoo2, parameter_n, DAC__RS__PLL_PARAMETER, 0);
|
dac_data_write(voodoo2, parameter_n, DAC__RS__PLL_PARAMETER);
|
||||||
wait_graphics_busy(voodoo2);
|
wait_graphics_busy(voodoo2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,29 +111,44 @@ typedef struct mn {
|
|||||||
uint8_t n;
|
uint8_t n;
|
||||||
} mn_t;
|
} mn_t;
|
||||||
|
|
||||||
static inline struct mn_t dac_read_16(voodoo2_reg * voodoo,
|
static inline mn_t dac_read_pll_16(voodoo2_reg * voodoo2,
|
||||||
int address)
|
int address)
|
||||||
{
|
{
|
||||||
dac_data_write(base, address, DAC__RS__PLL_ADDRESS_READ);
|
dac_data_write(voodoo2, address, DAC__RS__PLL_ADDRESS_READ);
|
||||||
wait_graphics_busy(base);
|
wait_graphics_busy(voodoo2);
|
||||||
|
|
||||||
dac_data_read(base, 0, DAC__RS__PLL_PARAMETER);
|
dac_data_read(voodoo2, 0, DAC__RS__PLL_PARAMETER);
|
||||||
wait_graphics_busy(base);
|
wait_graphics_busy(voodoo2);
|
||||||
int m = voodoo2->fbiInit2 & 0xff;
|
int m = voodoo2->fbiInit2 & 0xff;
|
||||||
|
|
||||||
dac_data_read(base, 0, DAC__RS__PLL_PARAMETER);
|
dac_data_read(voodoo2, 0, DAC__RS__PLL_PARAMETER);
|
||||||
wait_graphics_busy(base);
|
wait_graphics_busy(voodoo2);
|
||||||
int n = voodoo2->fbiInit2 & 0xff;
|
int n = voodoo2->fbiInit2 & 0xff;
|
||||||
|
|
||||||
return (struct m_n){ m, n };
|
return (mn_t){ m, n };
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const char * config = "/sys/bus/pci/devices/0000:02:0a.0/config";
|
const char * config_path = "/sys/bus/pci/devices/0000:02:0a.0/config";
|
||||||
int fd = open(config, O_RDWR | O_SYNC);
|
int fd = open(config_path, O_RDWR | O_SYNC);
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
|
|
||||||
|
uint32_t config_size = (sizeof (struct voodoo2_config));
|
||||||
|
|
||||||
|
void * config_base = mmap(0, config_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
assert(config_base != MAP_FAILED);
|
||||||
|
voodoo2_config * config = (voodoo2_config *)config_base;
|
||||||
|
|
||||||
|
printf("Vendor ID: %04x\n", config->Vendor_ID);
|
||||||
|
printf("Device ID: %04x\n", config->Device_ID);
|
||||||
|
|
||||||
|
munmap(config_base, config_size);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
const char * filename = "/sys/bus/pci/devices/0000:02:0a.0/resource0";
|
const char * filename = "/sys/bus/pci/devices/0000:02:0a.0/resource0";
|
||||||
|
|
||||||
int fd = open(filename, O_RDWR | O_SYNC);
|
int fd = open(filename, O_RDWR | O_SYNC);
|
||||||
@ -138,12 +156,12 @@ int main()
|
|||||||
|
|
||||||
uint32_t map_size = 0x4000;
|
uint32_t map_size = 0x4000;
|
||||||
|
|
||||||
off_t target_base = 0;
|
void * map_base = mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
void * map_base = mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target_base);
|
|
||||||
assert(map_base != MAP_FAILED);
|
assert(map_base != MAP_FAILED);
|
||||||
|
|
||||||
struct voodoo2_reg * reg = (struct voodoo2_reg *)map_base;
|
struct voodoo2_reg * reg = (struct voodoo2_reg *)map_base;
|
||||||
print_registers(reg);
|
print_registers(reg);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "reg32.h"
|
#include "reg.h"
|
||||||
|
|
||||||
|
|
||||||
struct voodoo2_reg {
|
struct voodoo2_reg {
|
||||||
reg32 status; // (r ) Voodoo2 Graphics Status
|
reg32 status; // (r ) Voodoo2 Graphics Status
|
||||||
@ -335,3 +334,6 @@ static_assert((offsetof (struct voodoo2_reg, trexInit0)) == 0x31c);
|
|||||||
static_assert((offsetof (struct voodoo2_reg, trexInit1)) == 0x320);
|
static_assert((offsetof (struct voodoo2_reg, trexInit1)) == 0x320);
|
||||||
static_assert((offsetof (struct voodoo2_reg, nccTable0[0])) == 0x324);
|
static_assert((offsetof (struct voodoo2_reg, nccTable0[0])) == 0x324);
|
||||||
static_assert((offsetof (struct voodoo2_reg, nccTable1[0])) == 0x354);
|
static_assert((offsetof (struct voodoo2_reg, nccTable1[0])) == 0x354);
|
||||||
|
|
||||||
|
typedef struct voodoo2_reg voodoo2_reg;
|
||||||
|
|
||||||
|
@ -52,3 +52,6 @@ static_assert((offsetof (struct voodoo2_config, busSnoop1)) == 0x48);
|
|||||||
static_assert((offsetof (struct voodoo2_config, cfgStatus)) == 0x4c);
|
static_assert((offsetof (struct voodoo2_config, cfgStatus)) == 0x4c);
|
||||||
static_assert((offsetof (struct voodoo2_config, cfgScratch)) == 0x50);
|
static_assert((offsetof (struct voodoo2_config, cfgScratch)) == 0x50);
|
||||||
static_assert((offsetof (struct voodoo2_config, siProcess)) == 0x54);
|
static_assert((offsetof (struct voodoo2_config, siProcess)) == 0x54);
|
||||||
|
|
||||||
|
typedef struct voodoo2_config voodoo2_config;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user