Skip to content

Commit

Permalink
fixup! macos: DriverKit core backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Baekalfen committed May 13, 2024
1 parent 8c51fc0 commit 1c7ebbd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
6 changes: 3 additions & 3 deletions include/vfn/driverkit/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

// NOTE: Dummy PROT to satisfy Linux code
enum {
PROT_READ=0,
PROT_WRITE=1,
PROT_READ = 0,
PROT_WRITE = 1,
};

// NOTE: Faux open for macOS
Expand All @@ -28,7 +28,7 @@ int vfio_pci_open(struct driverkit_pci_device *pci, const char *bdf);
* returns ``NULL`` and sets ``errno``.
*/
void *vfio_pci_map_bar(struct driverkit_pci_device *pci, int idx, size_t len, uint64_t offset,
int prot);
int prot);

/**
* vfio_pci_unmap_bar - faux unmap a region in virtual memory for DriverKit
Expand Down
28 changes: 14 additions & 14 deletions src/nvme/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ int errno;
#ifdef __APPLE__
inline void *cqhdbl(void *doorbells, int qid, int dstrd)
{
struct macvfn_pci_map_bar *doorbell_mapping = (struct macvfn_pci_map_bar*) doorbells;
struct macvfn_pci_map_bar *new_mapping = (struct macvfn_pci_map_bar*) zmallocn(1, sizeof(struct macvfn_pci_map_bar));
struct macvfn_pci_map_bar *doorbell_mapping = (struct macvfn_pci_map_bar*) doorbells;
struct macvfn_pci_map_bar *new_mapping = (struct macvfn_pci_map_bar*) zmallocn(1, sizeof(struct macvfn_pci_map_bar));

new_mapping->pci = doorbell_mapping->pci;
new_mapping->idx = doorbell_mapping->idx;
new_mapping->len = doorbell_mapping->len;
new_mapping->offset = doorbell_mapping->offset + (2 * qid + 1) * (4 << dstrd);
new_mapping->pci = doorbell_mapping->pci;
new_mapping->idx = doorbell_mapping->idx;
new_mapping->len = doorbell_mapping->len;
new_mapping->offset = doorbell_mapping->offset + (2 * qid + 1) * (4 << dstrd);

return new_mapping;
return new_mapping;
}

inline void *sqtdbl(void *doorbells, int qid, int dstrd)
{
struct macvfn_pci_map_bar *doorbell_mapping = (struct macvfn_pci_map_bar*) doorbells;
struct macvfn_pci_map_bar *new_mapping = (struct macvfn_pci_map_bar*) zmallocn(1, sizeof(struct macvfn_pci_map_bar));
struct macvfn_pci_map_bar *doorbell_mapping = (struct macvfn_pci_map_bar*) doorbells;
struct macvfn_pci_map_bar *new_mapping = (struct macvfn_pci_map_bar*) zmallocn(1, sizeof(struct macvfn_pci_map_bar));

new_mapping->pci = doorbell_mapping->pci;
new_mapping->idx = doorbell_mapping->idx;
new_mapping->len = doorbell_mapping->len;
new_mapping->offset = doorbell_mapping->offset + (2 * qid) * (4 << dstrd);
new_mapping->pci = doorbell_mapping->pci;
new_mapping->idx = doorbell_mapping->idx;
new_mapping->len = doorbell_mapping->len;
new_mapping->offset = doorbell_mapping->offset + (2 * qid) * (4 << dstrd);

return new_mapping;
return new_mapping;
}
#else
#define cqhdbl(doorbells, qid, dstrd) \
Expand Down
7 changes: 3 additions & 4 deletions src/pci/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ extern "C" {
#ifdef __APPLE__
int pci_device_info_get_ull(const char *bdf, const char *prop, unsigned long long *v)
{
if (!strcmp(prop, "class")){
// TODO: Actually read this from device once it makes sense
if (!strcmp(prop, "class")) {
// TODO: Actually read this from device once it makes sense
*v = 0x010800;
}
else{
} else {
return -1;
}
return 0;
Expand Down

0 comments on commit 1c7ebbd

Please sign in to comment.