Hello all,
I am writing a device driver for a PCIe storage device and I am having
trouble getting it off the ground.
When I attempt to access my device's registers using ddi_get32(), I get
back 0xffffffff when I should be getting back 0xcafebeef.
I assume I am missing some setup somewhere, but I can't figure out where.
My code looks like this:
static struct ddi_device_acc_attr dev_attr = {
DDI_DEVICE_ATTR_V0,
DDI_STRUCTURE_LE_ACC,
DDI_STRICTORDER_ACC,
DDI_DEFAULT_ACC
};
ddi_acc_handle_t regh;
uint32_t *regh;
static int pflash_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) {
uint32_t val;
:
/* This maps all 64k of the first BAR */
ddi_regs_map_setup(dip, 1, (caddr_t *)®r, 0, 0, &dev_attr,
®h);
:
val = ddi_get32(regh, regh);
cmn_err(CE_NOTE, "val = %x", val);
:
When I add my driver see the following in /var/adm/messages:
<date time sys> pflash: [ID 768250 kern.notice] NOTICE: val = ffffffff
When I use a PCI bus analyzer on my PCIe device, I see the hardware
respond to the register access with the data I expect. I just don't get
the data I expect in val.
If I write the register prior to reading it, like so:
ddi_put32(regh, regr, 0xdeaddead);
val = ddi_get32(regh, regr);
cmn_err(CE_NOTE, "val = %x", val);
I get the same print in my /var/adm/messages that I did before. Looking
at my PCI bus analyzer, I see the correct write data, 0xdeaddead,
written and read from the device's register space.
I have no idea why my driver would fail to give me my data. Can anyone
point me in the correct direction? I assume I am missing a step somewhere.
Thanks,
-Adam
_______________________________________________
driver-discuss mailing list
driver-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/driver-discuss