Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int nvme_init(char * rsdp)
- {
- ...
- /* get and store ECAM base address and starting and ending pcie bus number */
- pcie_ecam = (uint64_t *) *(mcfg + 44);
- start_bus_num = (uint8_t) *((char *) mcfg + 44 + 10);
- end_bus_num = (uint8_t) *((char *) mcfg + 44 + 11);
- /* enumerate pcie bus */
- printk("@@@debug\n");
- check_all_buses(start_bus_num, end_bus_num);
- printk("@@@debug\n");
- return 0;
- }
- uint64_t get_vendor_id(uint8_t bus, uint8_t start, uint8_t device, uint8_t function)
- {
- uint64_t *phy_addr;
- phy_addr = pcie_ecam + ((bus - start) << 20 | device << 15 | function << 12);
- return *phy_addr; /* hangs here */
- }
- void check_device(uint8_t bus, uint8_t start, uint8_t device)
- {
- uint8_t function = 0;
- uint16_t vendor_id;
- vendor_id = (uint16_t) get_vendor_id(bus, start, device, function);
- printk("@@@vendor_id={d}\n", (int) vendor_id);
- if (vendor_id == 0xFFFF) /* device doesn't exist */
- return;
- printk("device #{d} exists!\n", (int) device);
- /* TODO: check for class and subclass */
- }
- void check_all_buses(uint8_t start, uint8_t end)
- {
- uint8_t bus;
- uint8_t device;
- if(end == -1)
- end = start;
- for (bus = start; bus <= end; bus++) {
- for (device = 0; device < 32; device++) {
- check_device(bus, start, device);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement