From b7c81f0355379b9d0fcdf624a8df1b7119f28efc Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Sun, 10 Aug 2014 04:10:21 +1000 Subject: nvif: import library functions for the ioctl/event interfaces This is a wrapper around the interfaces defined in an earlier commit, and is also used by various userspace (either by a libdrm backend, or libpciaccess) tools/tests. In the future this will be extended to handle channels, replacing some long-unloved code we currently use, and allow fifo/display/mpeg (hi Ilia ;)) engines to all be exposed in the same way. Signed-off-by: Ben Skeggs --- bin/Makefile.am | 8 +++---- bin/nv_aux.c | 37 +++++++++++++++++------------- bin/nv_disp.c | 36 +++++++++++++----------------- bin/nv_i2c.c | 37 +++++++++++++++++------------- bin/nv_init.c | 39 +++++++++++++++++++------------- bin/nv_perfmon.c | 68 ++++++++++++++++++++++++++++++++------------------------ bin/nv_rd08.c | 2 +- bin/nv_rd16.c | 2 +- bin/nv_rd32.c | 2 +- bin/nv_rdfuc.c | 43 ++++++++++++++++++++--------------- bin/nv_rdfunc.h | 27 +++++++++++++++------- bin/nv_rffunc.h | 12 +++++----- bin/nv_rifunc.h | 12 +++++----- bin/nv_rs08.c | 2 +- bin/nv_rs16.c | 2 +- bin/nv_rs32.c | 2 +- bin/nv_rsfunc.h | 16 ++++++------- bin/nv_rv08.c | 2 +- bin/nv_rv16.c | 2 +- bin/nv_rv32.c | 2 +- bin/nv_rvfunc.h | 10 ++++----- bin/nv_wffunc.h | 12 +++++----- bin/nv_wifunc.h | 12 +++++----- bin/nv_wr08.c | 2 +- bin/nv_wr16.c | 2 +- bin/nv_wr32.c | 2 +- bin/nv_wrfunc.h | 27 +++++++++++++++------- bin/nv_ws08.c | 2 +- bin/nv_ws16.c | 2 +- bin/nv_ws32.c | 2 +- bin/nv_wsfunc.h | 10 ++++----- bin/nv_wv08.c | 2 +- bin/nv_wv16.c | 2 +- bin/nv_wv32.c | 2 +- bin/nv_wvfunc.h | 10 ++++----- 35 files changed, 243 insertions(+), 209 deletions(-) (limited to 'bin') diff --git a/bin/Makefile.am b/bin/Makefile.am index a32acd71b..13f75fd5e 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -7,9 +7,7 @@ bin_PROGRAMS = \ nv_disp nv_i2c nv_aux nv_init nv_rdfuc nv_perfmon AM_CPPFLAGS = -I$(top_srcdir)/nvkm/include \ - -I$(top_srcdir)/nvkm \ - -I$(top_srcdir)/lib/ + -I$(top_srcdir)/lib/ \ + -I$(top_srcdir)/ -LDADD = -lpciaccess -lncurses -lmenu -lform \ - $(top_srcdir)/lib/libpciaccessos.la \ - $(top_srcdir)/nvkm/libnouveau.la +LDFLAGS = $(top_srcdir)/nvif/libnvif.la -lncurses -lmenu -lform diff --git a/bin/nv_aux.c b/bin/nv_aux.c index a1e4fe81f..00da6b305 100644 --- a/bin/nv_aux.c +++ b/bin/nv_aux.c @@ -2,17 +2,11 @@ #include #include -#include -#include +#include +#include +#include #include -#include - -#include - -struct nouveau_object *client; -struct nouveau_object *device; - static void print_chan(struct nouveau_i2c_port *chan) { @@ -22,6 +16,12 @@ print_chan(struct nouveau_i2c_port *chan) int main(int argc, char **argv) { + const char *drv = "libnvkm"; + const char *cfg = NULL; + const char *dbg = "error"; + u64 dev = ~0ULL; + struct nvif_client *client; + struct nvif_device *device; struct nouveau_i2c_port *chan; struct nouveau_i2c *i2c; int action = -1, index = -1; @@ -29,8 +29,12 @@ main(int argc, char **argv) int ret, c; u8 data; - while ((c = getopt(argc, argv, "-")) != -1) { + while ((c = getopt(argc, argv, "-a:b:c:d:")) != -1) { switch (c) { + case 'a': dev = strtoull(optarg, NULL, 0); break; + case 'b': drv = optarg; break; + case 'c': cfg = optarg; break; + case 'd': dbg = optarg; break; case 1: if (action < 0) { if (!strcasecmp(optarg, "rd")) @@ -60,12 +64,12 @@ main(int argc, char **argv) } } - ret = os_client_new(NULL, "error", argc, argv, &client); + ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client); if (ret) return ret; - ret = nouveau_object_new(client, ~0, 0, 0x0080, - &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE_CLASS, + &(struct nv_device_class) { .device = ~0ULL, .disable = ~(NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY| @@ -73,11 +77,12 @@ main(int argc, char **argv) NV_DEVICE_DISABLE_CORE), .debug0 = ~((1 << NVDEV_SUBDEV_VBIOS) | (1 << NVDEV_SUBDEV_I2C)), - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_class), &device); + nvif_client_ref(NULL, &client); if (ret) return ret; - i2c = nouveau_i2c(device); + i2c = nvkm_i2c(device); if (action < 0) { list_for_each_entry(chan, &i2c->ports, head) { @@ -113,6 +118,6 @@ main(int argc, char **argv) } done: - os_client_del(&client); + nvif_device_ref(NULL, &device); return ret; } diff --git a/bin/nv_disp.c b/bin/nv_disp.c index b083e5219..7cf5a2c51 100644 --- a/bin/nv_disp.c +++ b/bin/nv_disp.c @@ -1,31 +1,27 @@ #include -#include -#include -#include +#include static unsigned long chan = 0; static void -nv_disp(struct nouveau_object *device, u16 mthd, u32 data) +nv_disp(struct nvif_device *device, u16 mthd, u32 data) { - if (nv_device(device)->card_type >= NV_50 && - nv_device(device)->chipset < 0xd0) { - u32 ctrl = nv_ro32(device, 0x610300 + (chan * 8)); - nv_wo32(device, 0x610300 + (chan * 8), ctrl | 0x00000001); - nv_wo32(device, 0x610304 + (chan * 8), data); - nv_wo32(device, 0x610300 + (chan * 8), mthd | 0x80000001); - while (nv_ro32(device, 0x610300 + (chan * 8)) & 0x80000000) {} - nv_wo32(device, 0x610300 + (chan * 8), ctrl); + if (device->info.chipset >= 0xd0) { + u32 ctrl = nvif_rd32(device, 0x610700 + (chan * 16)); + nvif_wr32(device, 0x610700 + (chan * 16), ctrl | 0x00000001); + nvif_wr32(device, 0x610704 + (chan * 16), data); + nvif_wr32(device, 0x610700 + (chan * 16), mthd | 0x80000001); + while (nvif_rd32(device, 0x610700 + (chan * 16)) & 0x80000000) {} + nvif_wr32(device, 0x610700 + (chan * 16), ctrl); } else - if (nv_device(device)->chipset >= 0xd0 && - nv_device(device)->card_type <= NV_E0) { - u32 ctrl = nv_ro32(device, 0x610700 + (chan * 16)); - nv_wo32(device, 0x610700 + (chan * 16), ctrl | 0x00000001); - nv_wo32(device, 0x610704 + (chan * 16), data); - nv_wo32(device, 0x610700 + (chan * 16), mthd | 0x80000001); - while (nv_ro32(device, 0x610700 + (chan * 16)) & 0x80000000) {} - nv_wo32(device, 0x610700 + (chan * 16), ctrl); + if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) { + u32 ctrl = nvif_rd32(device, 0x610300 + (chan * 8)); + nvif_wr32(device, 0x610300 + (chan * 8), ctrl | 0x00000001); + nvif_wr32(device, 0x610304 + (chan * 8), data); + nvif_wr32(device, 0x610300 + (chan * 8), mthd | 0x80000001); + while (nvif_rd32(device, 0x610300 + (chan * 8)) & 0x80000000) {} + nvif_wr32(device, 0x610300 + (chan * 8), ctrl); } else { printk("unsupported chipset\n"); exit(1); diff --git a/bin/nv_i2c.c b/bin/nv_i2c.c index 3b7114568..7b1c87952 100644 --- a/bin/nv_i2c.c +++ b/bin/nv_i2c.c @@ -2,17 +2,11 @@ #include #include -#include -#include +#include +#include +#include #include -#include - -#include - -struct nouveau_object *client; -struct nouveau_object *device; - static void print_port(struct nouveau_i2c_port *port) { @@ -22,14 +16,24 @@ print_port(struct nouveau_i2c_port *port) int main(int argc, char **argv) { + const char *drv = "libnvkm"; + const char *cfg = NULL; + const char *dbg = "error"; + u64 dev = ~0ULL; + struct nvif_client *client; + struct nvif_device *device; struct nouveau_i2c_port *port; struct nouveau_i2c *i2c; int addr = -1, reg = -1, val = -1; int action = -1, index = -1; int ret, c; - while ((c = getopt(argc, argv, "-")) != -1) { + while ((c = getopt(argc, argv, "-a:b:c:d:")) != -1) { switch (c) { + case 'a': dev = strtoull(optarg, NULL, 0); break; + case 'b': drv = optarg; break; + case 'c': cfg = optarg; break; + case 'd': dbg = optarg; break; case 1: if (action < 0) { if (!strcasecmp(optarg, "scan")) @@ -66,12 +70,12 @@ main(int argc, char **argv) } } - ret = os_client_new(NULL, "error", argc, argv, &client); + ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client); if (ret) return ret; - ret = nouveau_object_new(client, ~0, 0, 0x0080, - &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE_CLASS, + &(struct nv_device_class) { .device = ~0ULL, .disable = ~(NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY| @@ -79,11 +83,12 @@ main(int argc, char **argv) NV_DEVICE_DISABLE_CORE), .debug0 = ~((1 << NVDEV_SUBDEV_VBIOS) | (1 << NVDEV_SUBDEV_I2C)), - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_class), &device); + nvif_client_ref(NULL, &client); if (ret) return ret; - i2c = nouveau_i2c(device); + i2c = nvkm_i2c(device); if (action < 0) { list_for_each_entry(port, &i2c->ports, head) { @@ -146,6 +151,6 @@ main(int argc, char **argv) } done: - os_client_del(&client); + nvif_device_ref(NULL, &device); return ret; } diff --git a/bin/nv_init.c b/bin/nv_init.c index fcd8c6ede..d012aa79e 100644 --- a/bin/nv_init.c +++ b/bin/nv_init.c @@ -2,23 +2,30 @@ #include #include -#include -#include +#include +#include +#include +#include #include -#include - -struct nouveau_object *client; -struct nouveau_object *device; - int main(int argc, char **argv) { + const char *drv = NULL; + const char *cfg = NULL; + const char *dbg = "info"; + u64 dev = ~0ULL; + struct nvif_client *client; + struct nvif_device *device; bool suspend = false, wait = false; int ret, c; - while ((c = getopt(argc, argv, "-sw")) != -1) { + while ((c = getopt(argc, argv, "-a:b:c:d:sw")) != -1) { switch (c) { + case 'a': dev = strtoull(optarg, NULL, 0); break; + case 'b': drv = optarg; break; + case 'c': cfg = optarg; break; + case 'd': dbg = optarg; break; case 's': suspend = true; break; @@ -30,22 +37,23 @@ main(int argc, char **argv) } } - ret = os_client_new(NULL, "info", argc, argv, &client); + ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client); if (ret) return ret; - ret = nouveau_object_new(client, ~0, 0, 0x0080, - &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE_CLASS, + &(struct nv_device_class) { .device = ~0ULL, .disable = 0ULL, .debug0 = 0ULL, - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_class), &device); + nvif_client_ref(NULL, &client); if (ret) return ret; if (suspend) { - os_suspend(); - os_resume(); + client->driver->suspend(client); + client->driver->resume(client); } while (wait && (c = getchar()) == EOF) { @@ -53,8 +61,7 @@ main(int argc, char **argv) } printf("shutting down...\n"); - os_client_del(&client); - nouveau_object_debug(); + nvif_device_ref(NULL, &device); printf("done!\n"); return ret; } diff --git a/bin/nv_perfmon.c b/bin/nv_perfmon.c index 9285d7dbe..611a327a0 100644 --- a/bin/nv_perfmon.c +++ b/bin/nv_perfmon.c @@ -28,14 +28,14 @@ #include #include -#include -#include +#include +#include +#include #include #include -static struct nouveau_object *client; -static struct nouveau_object *device; +static struct nvif_device *device; static char **signals; static int nr_signals; @@ -250,7 +250,7 @@ ui_menu_win = { struct ui_main { struct list_head head; u32 handle; - struct nouveau_object *object; + struct nvif_object object; const char *name; u32 clk; u32 ctr; @@ -263,7 +263,7 @@ static u32 ui_main_handle = 0xc0000000; static void ui_main_remove(struct ui_main *item) { - int ret = nouveau_object_del(client, 0x00000000, item->handle); + nvif_object_fini(&item->object); list_del(&item->head); free(item); } @@ -281,20 +281,19 @@ ui_main_select(void) for (i = 0; i < nr_signals; i++) { item = calloc(1, sizeof(*item)); item->handle = ui_main_handle++; - item->object = NULL; item->name = signals[i]; item->incr = 0; - ret = nouveau_object_new(client, 0x00000000, item->handle, - NV_PERFCTR_CLASS, - &(struct nv_perfctr_class) { + ret = nvif_object_init(nvif_object(device), NULL, item->handle, + NV_PERFCTR_CLASS, + &(struct nv_perfctr_class) { .logic_op = 0xaaaa, .signal[0].name = (char *)item->name, .signal[0].size = strlen(item->name) - }, sizeof(struct nv_perfctr_class), - &item->object); + }, sizeof(struct nv_perfctr_class), + &item->object); assert(ret == 0); list_add_tail(&item->head, &ui_main_list); } @@ -315,13 +314,14 @@ ui_main_alarm_handler(int signal) if (!sampled) { struct nv_perfctr_sample args; - ret = nv_exec(item->object, NV_PERFCTR_SAMPLE, - &args, sizeof(args)); + ret = nvif_exec(&item->object, NV_PERFCTR_SAMPLE, + &args, sizeof(args)); assert(ret == 0); sampled = true; } - ret = nv_exec(item->object, NV_PERFCTR_READ, &args, sizeof(args)); + ret = nvif_exec(&item->object, NV_PERFCTR_READ, + &args, sizeof(args)); assert(ret == 0 || ret == -EAGAIN); if (ret == 0) { @@ -598,13 +598,22 @@ ui_resize(void) int main(int argc, char **argv) { + const char *drv = NULL; + const char *cfg = NULL; + const char *dbg = "error"; + u64 dev = ~0ULL; + struct nvif_client *client; struct nv_perfctr_query args = {}; - struct nouveau_object *object; + struct nvif_object object; int ret, c, k; int scan = 0; - while ((c = getopt(argc, argv, "-s")) != -1) { + while ((c = getopt(argc, argv, "-a:b:c:d:s")) != -1) { switch (c) { + case 'a': dev = strtoull(optarg, NULL, 0); break; + case 'b': drv = optarg; break; + case 'c': cfg = optarg; break; + case 'd': dbg = optarg; break; case 's': scan = 1; break; @@ -613,13 +622,12 @@ main(int argc, char **argv) } } - - ret = os_client_new(NULL, "error", argc, argv, &client); + ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client); if (ret) return ret; - ret = nouveau_object_new(client, 0xffffffff, 0x00000000, - NV_DEVICE_CLASS, &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0x00000000, + NV_DEVICE_CLASS, &(struct nv_device_class) { .device = ~0ULL, .disable = ~(NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_VBIOS | @@ -627,7 +635,8 @@ main(int argc, char **argv) NV_DEVICE_DISABLE_IDENTIFY), .debug0 = ~((1ULL << NVDEV_SUBDEV_TIMER) | (1ULL << NVDEV_ENGINE_PERFMON)), - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_class), &device); + nvif_client_ref(NULL, &client); if (ret) return ret; @@ -636,15 +645,15 @@ main(int argc, char **argv) return 1; } - ret = nouveau_object_new(client, 0x00000000, 0xdeadbeef, - NV_PERFCTR_CLASS, &(struct nv_perfctr_class) { - }, sizeof(struct nv_perfctr_class), &object); + ret = nvif_object_init(nvif_object(device), NULL, 0xdeadbeef, + NV_PERFCTR_CLASS, &(struct nv_perfctr_class) { + }, sizeof(struct nv_perfctr_class), &object); assert(ret == 0); do { u32 prev_iter = args.iter; args.name = NULL; - ret = nv_exec(object, NV_PERFCTR_QUERY, &args, sizeof(args)); + ret = nvif_exec(&object, NV_PERFCTR_QUERY, &args, sizeof(args)); assert(ret == 0); if (prev_iter) { @@ -654,12 +663,12 @@ main(int argc, char **argv) args.iter = prev_iter; args.name = signals[nr_signals - 1]; - ret = nv_exec(object, NV_PERFCTR_QUERY, - &args, sizeof(args)); + ret = nvif_exec(&object, NV_PERFCTR_QUERY, + &args, sizeof(args)); assert(ret == 0); } } while (args.iter != 0xffffffff); - nouveau_object_del(client, 0x00000000, 0xdeadbeef); + nvif_object_fini(&object); initscr(); keypad(stdscr, TRUE); @@ -692,5 +701,6 @@ main(int argc, char **argv) while (nr_signals--) free(signals[nr_signals]); free(signals); + nvif_device_ref(NULL, &device); return 0; } diff --git a/bin/nv_rd08.c b/bin/nv_rd08.c index f3384416f..f368951fa 100644 --- a/bin/nv_rd08.c +++ b/bin/nv_rd08.c @@ -2,6 +2,6 @@ #define FMTDATA "0x%02x" #define NAME "nv_rd08" #define CAST u8 -#define READ(o) nv_ro08(device, (o)) +#define READ(o) nvif_rd08(device, (o)) #define MAIN main #include "nv_rdfunc.h" diff --git a/bin/nv_rd16.c b/bin/nv_rd16.c index 4c37cb7a5..0b48a0b4f 100644 --- a/bin/nv_rd16.c +++ b/bin/nv_rd16.c @@ -2,6 +2,6 @@ #define FMTDATA "0x%04x" #define NAME "nv_rd16" #define CAST u16 -#define READ(o) nv_ro16(device, (o)) +#define READ(o) nvif_rd16(device, (o)) #define MAIN main #include "nv_rdfunc.h" diff --git a/bin/nv_rd32.c b/bin/nv_rd32.c index 95cbd3b5c..88022a950 100644 --- a/bin/nv_rd32.c +++ b/bin/nv_rd32.c @@ -2,6 +2,6 @@ #define FMTDATA "0x%08x" #define NAME "nv_rd32" #define CAST u32 -#define READ(o) nv_ro32(device, (o)) +#define READ(o) nvif_rd32(device, (o)) #define MAIN main #include "nv_rdfunc.h" diff --git a/bin/nv_rdfuc.c b/bin/nv_rdfuc.c index 540ac4253..1478eb13d 100644 --- a/bin/nv_rdfuc.c +++ b/bin/nv_rdfuc.c @@ -2,21 +2,28 @@ #include #include -#include -#include +#include +#include +#include #include int main(int argc, char **argv) { - struct nouveau_object *client; - struct nouveau_object *device; + const char *drv = NULL; + const char *cfg = NULL; + const char *dbg = "error"; + u64 dev = ~0ULL; + struct nvif_client *client; + struct nvif_device *device; u32 fucbase = ~0; int segment = -1; int ret, c, i; - while ((c = getopt(argc, argv, "-cd")) != -1) { + while ((c = getopt(argc, argv, "-a:b:cd")) != -1) { switch (c) { + case 'a': dev = strtoull(optarg, NULL, 0); break; + case 'b': drv = optarg; break; case 'c': segment = 0; break; @@ -32,35 +39,35 @@ main(int argc, char **argv) if (fucbase == ~0 || segment < 0 || segment > 1) return 1; - ret = os_client_new(NULL, "info", argc, argv, &client); + ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client); if (ret) return ret; - ret = nouveau_object_new(client, ~0, 0, 0x0080, - &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE_CLASS, + &(struct nv_device_class) { .device = ~0ULL, .disable = ~NV_DEVICE_DISABLE_MMIO, .debug0 = 0, - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_class), &device); + nvif_client_ref(NULL, &client); if (ret) return ret; if (segment == 0) { - u32 size = (nv_ro32(device, fucbase + 0x0108) & 0x1ff) << 8; - nv_wo32(device, fucbase + 0x0180, 0x02000000); + u32 size = (nvif_rd32(device, fucbase + 0x0108) & 0x1ff) << 8; + nvif_wr32(device, fucbase + 0x0180, 0x02000000); for (i = 0; i < size; i += 4) { if (!(i & 0xff)) - nv_wo32(device, fucbase + 0x0188, i >> 8); - printf("0x%08x\n", nv_ro32(device, fucbase + 0x0184)); + nvif_wr32(device, fucbase + 0x0188, i >> 8); + printf("0x%08x\n", nvif_rd32(device, fucbase + 0x0184)); } } else { - u32 size = (nv_ro32(device, fucbase + 0x0108) & 0x3fe00) >> 1; - nv_wo32(device, fucbase + 0x01c0, 0x02000000); + u32 size = (nvif_rd32(device, fucbase + 0x0108) & 0x3fe00) >> 1; + nvif_wr32(device, fucbase + 0x01c0, 0x02000000); for (i = 0; i < size; i += 4) - printf("0x%08x\n", nv_ro32(device, fucbase + 0x01c4)); + printf("0x%08x\n", nvif_rd32(device, fucbase + 0x01c4)); } - - os_client_del(&client); + nvif_device_ref(NULL, &device); return 0; } diff --git a/bin/nv_rdfunc.h b/bin/nv_rdfunc.h index d840ddd3e..fef29de7a 100644 --- a/bin/nv_rdfunc.h +++ b/bin/nv_rdfunc.h @@ -2,8 +2,9 @@ #include #include -#include -#include +#include +#include +#include #include #ifndef ENABLE @@ -16,8 +17,12 @@ int main(int argc, char **argv) { - struct nouveau_object *client; - struct nouveau_object *device; + const char *drv = NULL; + const char *cfg = NULL; + const char *dbg = "fatal"; + u64 dev = ~0ULL; + struct nvif_client *client; + struct nvif_device *device; struct nv_device_class args; char *rstr = NULL; enum { @@ -34,8 +39,12 @@ main(int argc, char **argv) int ndata = 0; int ret, c; - while ((c = getopt(argc, argv, "-qrw")) != -1) { + while ((c = getopt(argc, argv, "-a:b:c:d:qrw")) != -1) { switch (c) { + case 'a': dev = strtoull(optarg, NULL, 0); break; + case 'b': drv = optarg; break; + case 'c': cfg = optarg; break; + case 'd': dbg = optarg; break; case 'q': mode = QUIET; break; case 'r': mode = RATES; break; case 'w': mode = WATCH; break; @@ -47,7 +56,7 @@ main(int argc, char **argv) } } - ret = os_client_new(NULL, "fatal", argc, argv, &client); + ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client); if (ret) return ret; @@ -55,8 +64,9 @@ main(int argc, char **argv) args.disable = ~ENABLE; args.debug0 = ~DEBUG0; - ret = nouveau_object_new(client, ~0, 0, 0x0080, &args, sizeof(args), - &device); + ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE_CLASS, + &args, sizeof(args), &device); + nvif_client_ref(NULL, &client); if (ret) return ret; @@ -140,5 +150,6 @@ main(int argc, char **argv) } free(data); + nvif_device_ref(NULL, &device); return 0; } diff --git a/bin/nv_rffunc.h b/bin/nv_rffunc.h index f7db0317f..31dc5c88e 100644 --- a/bin/nv_rffunc.h +++ b/bin/nv_rffunc.h @@ -1,20 +1,18 @@ #include -#include -#include -#include +#include static void __iomem *map = NULL; static u64 map_page = ~0ULL; static CAST -nv_rfb(struct nouveau_object *device, u64 offset) +nv_rfb(struct nvif_device *device, u64 offset) { u64 page = (offset & ~(PAGE_SIZE - 1)); u64 addr = (offset & (PAGE_SIZE - 1)); - if (nv_device(device)->card_type < NV_04 || - nv_device(device)->card_type > NV_E0) { + if (device->info.family < NV_DEVICE_INFO_V0_TNT || + device->info.family > NV_DEVICE_INFO_V0_MAXWELL) { printk("unsupported chipset\n"); exit(1); } @@ -23,7 +21,7 @@ nv_rfb(struct nouveau_object *device, u64 offset) if (map) iounmap(map); - map = ioremap(pci_resource_start(nv_device(device)->pdev, 1) + + map = ioremap(pci_resource_start(nvkm_device(device)->pdev, 1) + page, PAGE_SIZE); if (!map) { printk("map failed\n"); diff --git a/bin/nv_rifunc.h b/bin/nv_rifunc.h index 82fa77ba7..8041ea1b4 100644 --- a/bin/nv_rifunc.h +++ b/bin/nv_rifunc.h @@ -1,21 +1,19 @@ #include -#include -#include -#include +#include static void __iomem *map = NULL; static u64 map_page = ~0ULL; static CAST -nv_rfb(struct nouveau_object *device, u64 offset) +nv_rfb(struct nvif_device *device, u64 offset) { - struct pci_dev *pdev = nv_device(device)->pdev; + struct pci_dev *pdev = nvkm_device(device)->pdev; u64 page = (offset & ~(PAGE_SIZE - 1)); u64 addr = (offset & (PAGE_SIZE - 1)); - if (nv_device(device)->card_type < NV_40 || - nv_device(device)->card_type > NV_E0) { + if (device->info.family < NV_DEVICE_INFO_V0_CURIE || + device->info.family > NV_DEVICE_INFO_V0_MAXWELL) { printk("unsupported chipset\n"); exit(1); } diff --git a/bin/nv_rs08.c b/bin/nv_rs08.c index b379d7fe8..63ad4f206 100644 --- a/bin/nv_rs08.c +++ b/bin/nv_rs08.c @@ -3,5 +3,5 @@ #define NAME "nv_rs08" #define CAST u8 #define MAIN main -#define RSYS nv_ro08 +#define RSYS nvif_rd08 #include "nv_rsfunc.h" diff --git a/bin/nv_rs16.c b/bin/nv_rs16.c index 6582197e6..148ee85c7 100644 --- a/bin/nv_rs16.c +++ b/bin/nv_rs16.c @@ -3,5 +3,5 @@ #define NAME "nv_rs16" #define CAST u16 #define MAIN main -#define RSYS nv_ro16 +#define RSYS nvif_rd16 #include "nv_rsfunc.h" diff --git a/bin/nv_rs32.c b/bin/nv_rs32.c index 326f49fd9..d29eb8755 100644 --- a/bin/nv_rs32.c +++ b/bin/nv_rs32.c @@ -3,5 +3,5 @@ #define NAME "nv_rs32" #define CAST u32 #define MAIN main -#define RSYS nv_ro32 +#define RSYS nvif_rd32 #include "nv_rsfunc.h" diff --git a/bin/nv_rsfunc.h b/bin/nv_rsfunc.h index c73f1f737..47b53fee8 100644 --- a/bin/nv_rsfunc.h +++ b/bin/nv_rsfunc.h @@ -1,19 +1,17 @@ #include -#include -#include -#include +#include static CAST -nv_rsys(struct nouveau_object *device, u64 addr) +nv_rsys(struct nvif_device *device, u64 addr) { - if (nv_device(device)->card_type >= NV_50 && - nv_device(device)->card_type <= NV_E0) { + if (device->info.family >= NV_DEVICE_INFO_V0_TESLA && + device->info.family <= NV_DEVICE_INFO_V0_MAXWELL) { CAST data; - u32 pmem = nv_ro32(device, 0x001700); - nv_wo32(device, 0x001700, 0x02000000 | (addr >> 16)); + u32 pmem = nvif_rd32(device, 0x001700); + nvif_wr32(device, 0x001700, 0x02000000 | (addr >> 16)); data = RSYS(device, 0x700000 + (addr & 0xffffULL)); - nv_wo32(device, 0x001700, pmem); + nvif_wr32(device, 0x001700, pmem); return data; } else { printk("unsupported chipset\n"); diff --git a/bin/nv_rv08.c b/bin/nv_rv08.c index 1b51c8f40..92a5ffbf1 100644 --- a/bin/nv_rv08.c +++ b/bin/nv_rv08.c @@ -3,5 +3,5 @@ #define NAME "nv_rv08" #define CAST u8 #define MAIN main -#define RVRAM nv_ro08 +#define RVRAM nvif_rd08 #include "nv_rvfunc.h" diff --git a/bin/nv_rv16.c b/bin/nv_rv16.c index 9f6b6e47e..c39e02da6 100644 --- a/bin/nv_rv16.c +++ b/bin/nv_rv16.c @@ -3,5 +3,5 @@ #define NAME "nv_rv16" #define CAST u16 #define MAIN main -#define RVRAM nv_ro16 +#define RVRAM nvif_rd16 #include "nv_rvfunc.h" diff --git a/bin/nv_rv32.c b/bin/nv_rv32.c index d147bf17a..f8320bea9 100644 --- a/bin/nv_rv32.c +++ b/bin/nv_rv32.c @@ -3,5 +3,5 @@ #define NAME "nv_rv32" #define CAST u32 #define MAIN main -#define RVRAM nv_ro32 +#define RVRAM nvif_rd32 #include "nv_rvfunc.h" diff --git a/bin/nv_rvfunc.h b/bin/nv_rvfunc.h index 18f43219c..590e959b2 100644 --- a/bin/nv_rvfunc.h +++ b/bin/nv_rvfunc.h @@ -1,14 +1,12 @@ #include -#include -#include -#include +#include static CAST -nv_rvram(struct nouveau_object *device, u64 addr) +nv_rvram(struct nvif_device *device, u64 addr) { - if (nv_device(device)->card_type >= NV_50 && - nv_device(device)->card_type <= NV_E0) { + if (device->info.family >= NV_DEVICE_INFO_V0_TESLA && + device->info.family <= NV_DEVICE_INFO_V0_MAXWELL) { CAST data; u32 pmem = nv_ro32(device, 0x001700); nv_wo32(device, 0x001700, 0x00000000 | (addr >> 16)); diff --git a/bin/nv_wffunc.h b/bin/nv_wffunc.h index 4166afd89..6aaf13176 100644 --- a/bin/nv_wffunc.h +++ b/bin/nv_wffunc.h @@ -1,20 +1,18 @@ #include -#include -#include -#include +#include static void __iomem *map = NULL; static u64 map_page = ~0ULL; static void -nv_wfb(struct nouveau_object *device, u64 offset, CAST data) +nv_wfb(struct nvif_device *device, u64 offset, CAST data) { u64 page = (offset & ~(PAGE_SIZE - 1)); u64 addr = (offset & (PAGE_SIZE - 1)); - if (nv_device(device)->card_type < NV_04 || - nv_device(device)->card_type > NV_E0) { + if (device->info.family < NV_DEVICE_INFO_V0_TNT || + device->info.family > NV_DEVICE_INFO_V0_MAXWELL) { printk("unsupported chipset\n"); exit(1); } @@ -23,7 +21,7 @@ nv_wfb(struct nouveau_object *device, u64 offset, CAST data) if (map) iounmap(map); - map = ioremap(pci_resource_start(nv_device(device)->pdev, 1) + + map = ioremap(pci_resource_start(nvkm_device(device)->pdev, 1) + page, PAGE_SIZE); if (!map) { printk("map failed\n"); diff --git a/bin/nv_wifunc.h b/bin/nv_wifunc.h index fa47d69ce..2ae519228 100644 --- a/bin/nv_wifunc.h +++ b/bin/nv_wifunc.h @@ -1,21 +1,19 @@ #include -#include -#include -#include +#include static void __iomem *map = NULL; static u64 map_page = ~0ULL; static void -nv_wfb(struct nouveau_object *device, u64 offset, CAST data) +nv_wfb(struct nvif_device *device, u64 offset, CAST data) { - struct pci_dev *pdev = nv_device(device)->pdev; + struct pci_dev *pdev = nvkm_device(device)->pdev; u64 page = (offset & ~(PAGE_SIZE - 1)); u64 addr = (offset & (PAGE_SIZE - 1)); - if (nv_device(device)->card_type < NV_40 || - nv_device(device)->card_type > NV_E0) { + if (device->info.family < NV_DEVICE_INFO_V0_CURIE || + device->info.family > NV_DEVICE_INFO_V0_MAXWELL) { printk("unsupported chipset\n"); exit(1); } diff --git a/bin/nv_wr08.c b/bin/nv_wr08.c index 184bfef46..c81b69a79 100644 --- a/bin/nv_wr08.c +++ b/bin/nv_wr08.c @@ -2,6 +2,6 @@ #define FMTDATA "0x%02x" #define NAME "nv_wr08" #define CAST u8 -#define WRITE(o,v) nv_wo08(device, (o), (v)) +#define WRITE(o,v) nvif_wr08(device, (o), (v)) #define MAIN main #include "nv_wrfunc.h" diff --git a/bin/nv_wr16.c b/bin/nv_wr16.c index 0e2271eb6..004b198a3 100644 --- a/bin/nv_wr16.c +++ b/bin/nv_wr16.c @@ -2,6 +2,6 @@ #define FMTDATA "0x%04x" #define NAME "nv_wr16" #define CAST u16 -#define WRITE(o,v) nv_wo16(device, (o), (v)) +#define WRITE(o,v) nvif_wr16(device, (o), (v)) #define MAIN main #include "nv_wrfunc.h" diff --git a/bin/nv_wr32.c b/bin/nv_wr32.c index 6dd188840..2b8b60f32 100644 --- a/bin/nv_wr32.c +++ b/bin/nv_wr32.c @@ -2,6 +2,6 @@ #define FMTDATA "0x%08x" #define NAME "nv_wr32" #define CAST u32 -#define WRITE(o,v) nv_wo32(device, (o), (v)) +#define WRITE(o,v) nvif_wr32(device, (o), (v)) #define MAIN main #include "nv_wrfunc.h" diff --git a/bin/nv_wrfunc.h b/bin/nv_wrfunc.h index eae75c248..c0e24efd1 100644 --- a/bin/nv_wrfunc.h +++ b/bin/nv_wrfunc.h @@ -2,8 +2,9 @@ #include #include -#include -#include +#include +#include +#include #include #ifndef ENABLE @@ -16,16 +17,24 @@ int MAIN(int argc, char **argv) { - struct nouveau_object *client; - struct nouveau_object *device; + const char *drv = NULL; + const char *cfg = NULL; + const char *dbg = "fatal"; + u64 dev = ~0ULL; + struct nvif_client *client; + struct nvif_device *device; struct nv_device_class args; char *rstr = NULL; char *vstr = NULL; int quiet = 0; int ret, c; - while ((c = getopt(argc, argv, "-q")) != -1) { + while ((c = getopt(argc, argv, "-a:b:c:d:q")) != -1) { switch (c) { + case 'a': dev = strtoull(optarg, NULL, 0); break; + case 'b': drv = optarg; break; + case 'c': cfg = optarg; break; + case 'd': dbg = optarg; break; case 'q': quiet = 1; break; @@ -41,7 +50,7 @@ MAIN(int argc, char **argv) } } - ret = os_client_new(NULL, "fatal", argc, argv, &client); + ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client); if (ret) return ret; @@ -49,8 +58,9 @@ MAIN(int argc, char **argv) args.disable = ~ENABLE; args.debug0 = ~DEBUG0; - ret = nouveau_object_new(client, ~0, 0, 0x0080, &args, sizeof(args), - &device); + ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE_CLASS, + &args, sizeof(args), &device); + nvif_client_ref(NULL, &client); if (ret) return ret; @@ -97,5 +107,6 @@ MAIN(int argc, char **argv) } } + nvif_device_ref(NULL, &device); return 0; } diff --git a/bin/nv_ws08.c b/bin/nv_ws08.c index 5d49f2edc..3a301d3e8 100644 --- a/bin/nv_ws08.c +++ b/bin/nv_ws08.c @@ -3,5 +3,5 @@ #define NAME "nv_rs08" #define CAST u8 #define MAIN main -#define WSYS nv_wo08 +#define WSYS nvif_wr08 #include "nv_wsfunc.h" diff --git a/bin/nv_ws16.c b/bin/nv_ws16.c index a3f0702be..d53d1f6c5 100644 --- a/bin/nv_ws16.c +++ b/bin/nv_ws16.c @@ -3,5 +3,5 @@ #define NAME "nv_ws16" #define CAST u16 #define MAIN main -#define WSYS nv_wo16 +#define WSYS nvif_wr16 #include "nv_wsfunc.h" diff --git a/bin/nv_ws32.c b/bin/nv_ws32.c index 78756fe09..26103e064 100644 --- a/bin/nv_ws32.c +++ b/bin/nv_ws32.c @@ -3,5 +3,5 @@ #define NAME "nv_ws32" #define CAST u32 #define MAIN main -#define WSYS nv_wo32 +#define WSYS nvif_wr32 #include "nv_wsfunc.h" diff --git a/bin/nv_wsfunc.h b/bin/nv_wsfunc.h index 596eede5f..70feefb10 100644 --- a/bin/nv_wsfunc.h +++ b/bin/nv_wsfunc.h @@ -1,14 +1,12 @@ #include -#include -#include -#include +#include static void -nv_wsys(struct nouveau_object *device, u64 addr, CAST data) +nv_wsys(struct nvif_device *device, u64 addr, CAST data) { - if (nv_device(device)->card_type >= NV_50 && - nv_device(device)->card_type <= NV_E0) { + if (device->info.family >= NV_DEVICE_INFO_V0_TESLA && + device->info.family <= NV_DEVICE_INFO_V0_MAXWELL) { u32 pmem = nv_ro32(device, 0x001700); nv_wo32(device, 0x001700, 0x02000000 | (addr >> 16)); WSYS(device, 0x700000 + (addr & 0xffffULL), data); diff --git a/bin/nv_wv08.c b/bin/nv_wv08.c index c78d42e83..7c032b4f8 100644 --- a/bin/nv_wv08.c +++ b/bin/nv_wv08.c @@ -3,5 +3,5 @@ #define NAME "nv_wv08" #define CAST u8 #define MAIN main -#define WVRAM nv_wo08 +#define WVRAM nvif_wr08 #include "nv_wvfunc.h" diff --git a/bin/nv_wv16.c b/bin/nv_wv16.c index d738cf89f..853330657 100644 --- a/bin/nv_wv16.c +++ b/bin/nv_wv16.c @@ -3,5 +3,5 @@ #define NAME "nv_wv16" #define CAST u16 #define MAIN main -#define WVRAM nv_wo16 +#define WVRAM nvif_wr16 #include "nv_wvfunc.h" diff --git a/bin/nv_wv32.c b/bin/nv_wv32.c index ba381a38e..e414246c6 100644 --- a/bin/nv_wv32.c +++ b/bin/nv_wv32.c @@ -3,5 +3,5 @@ #define NAME "nv_wv32" #define CAST u32 #define MAIN main -#define WVRAM nv_wo32 +#define WVRAM nvif_wr32 #include "nv_wvfunc.h" diff --git a/bin/nv_wvfunc.h b/bin/nv_wvfunc.h index 1f218ffc6..2832f168d 100644 --- a/bin/nv_wvfunc.h +++ b/bin/nv_wvfunc.h @@ -1,14 +1,12 @@ #include -#include -#include -#include +#include static void -nv_wvram(struct nouveau_object *device, u64 addr, CAST data) +nv_wvram(struct nvif_device *device, u64 addr, CAST data) { - if (nv_device(device)->card_type >= NV_50 && - nv_device(device)->card_type <= NV_E0) { + if (device->info.family >= NV_DEVICE_INFO_V0_TESLA && + device->info.family <= NV_DEVICE_INFO_V0_MAXWELL) { u32 pmem = nv_ro32(device, 0x001700); nv_wo32(device, 0x001700, 0x00000000 | (addr >> 16)); WVRAM(device, 0x700000 + (addr & 0xffffULL), data); -- cgit v1.2.1