diff --git a/src/userland/buffersTests/main.c b/src/userland/buffersTests/main.c index 12cdef0..eff6473 100644 --- a/src/userland/buffersTests/main.c +++ b/src/userland/buffersTests/main.c @@ -1,39 +1,11 @@ #include #include -#define SAMPLE_2_ARRAY_CONTENT(X, S) \ - X(INTEGER, 1) S \ - X(STRING, "hi") S \ - X(INTEGER, 500, Signed) - -#define SAMPLE_2(X) \ - X(ARRAY, SAMPLE_2_ARRAY_CONTENT) - -#define SAMPLE_3_MAP_CONTENTS(X, S) \ - X(INTEGER, 1) S \ - X(ARRAY, SAMPLE_2_ARRAY_CONTENT) S \ - X(STRING, "hello") S \ - X(STRING, "world") S \ - X(INTEGER, 2) S \ - X(STRING, "Number 2") S \ - X(STRING, "number") S \ - X(INTEGER, 1) - -#define SAMPLE_3(X) \ - X(MAP, SAMPLE_3_MAP_CONTENTS) - -uint32_t testFunction(void *data) { - GET(STRING, hello); - GET(INT, number); - - printf("parameters: hello=%s, number=%i\n", hello, number); - free(hello); - return 0; -} +REQUEST(pciDump, "lspci", "dump"); int32_t main() { - CREATE(test, SAMPLE_3); - msgPackDump(test); - testFunction(test); - free(test); + uintptr_t dataPhysical = pciDump(1, 0); + void *data = requestMemory(1, NULL, PTR(dataPhysical)); + printf("pci data for device 1:\n"); + msgPackDump(data); } \ No newline at end of file diff --git a/src/userland/buffersTests/main.c b/src/userland/buffersTests/main.c index 12cdef0..eff6473 100644 --- a/src/userland/buffersTests/main.c +++ b/src/userland/buffersTests/main.c @@ -1,39 +1,11 @@ #include #include -#define SAMPLE_2_ARRAY_CONTENT(X, S) \ - X(INTEGER, 1) S \ - X(STRING, "hi") S \ - X(INTEGER, 500, Signed) - -#define SAMPLE_2(X) \ - X(ARRAY, SAMPLE_2_ARRAY_CONTENT) - -#define SAMPLE_3_MAP_CONTENTS(X, S) \ - X(INTEGER, 1) S \ - X(ARRAY, SAMPLE_2_ARRAY_CONTENT) S \ - X(STRING, "hello") S \ - X(STRING, "world") S \ - X(INTEGER, 2) S \ - X(STRING, "Number 2") S \ - X(STRING, "number") S \ - X(INTEGER, 1) - -#define SAMPLE_3(X) \ - X(MAP, SAMPLE_3_MAP_CONTENTS) - -uint32_t testFunction(void *data) { - GET(STRING, hello); - GET(INT, number); - - printf("parameters: hello=%s, number=%i\n", hello, number); - free(hello); - return 0; -} +REQUEST(pciDump, "lspci", "dump"); int32_t main() { - CREATE(test, SAMPLE_3); - msgPackDump(test); - testFunction(test); - free(test); + uintptr_t dataPhysical = pciDump(1, 0); + void *data = requestMemory(1, NULL, PTR(dataPhysical)); + printf("pci data for device 1:\n"); + msgPackDump(data); } \ No newline at end of file diff --git a/src/userland/lspci/main.c b/src/userland/lspci/main.c index cbc8975..7934528 100644 --- a/src/userland/lspci/main.c +++ b/src/userland/lspci/main.c @@ -132,12 +132,14 @@ int32_t getBaseAddress(uint32_t deviceId, uint32_t n); int32_t enableBusMaster(uint32_t deviceId); int32_t getPCIInterrupt(uint32_t deviceId); +uintptr_t dump(uint32_t device); void initializePci() { createFunction("getDeviceClass", (void *)getDeviceClass); createFunction("getBaseAddress", (void *)getBaseAddress); createFunction("enableBusMaster", (void *)enableBusMaster); createFunction("getInterrupt", (void *)getPCIInterrupt); + createFunction("dump", (void *)dump); if (!(pciConfigRead(0, 0, 0, 0x0E) & 0x80)) { checkBus(0); } else { @@ -183,6 +185,31 @@ 0xFF; } +#define DEVICE_DUMP_BARS(X, S) \ + X(INTEGER, device->bar[0]) S \ + X(INTEGER, device->bar[1]) S \ + X(INTEGER, device->bar[2]) S \ + X(INTEGER, device->bar[3]) S \ + X(INTEGER, device->bar[4]) + +#define DEVICE_DUMP_MAP_DATA(X, S) \ + X(STRING, "bars") S \ + X(ARRAY, DEVICE_DUMP_BARS) S \ + X(STRING, "class") S \ + X(INTEGER, device->class << 16 | device->subclass << 8 | device->programmingInterface) + +#define DEVICE_DUMP(X) X(MAP, DEVICE_DUMP_MAP_DATA) + +uintptr_t dump(uint32_t deviceId) { + GET_HEADER + CREATE(data, DEVICE_DUMP); + void *resultBuffer = requestMemory(1, NULL, NULL); + memcpy(data, resultBuffer, dataLength); + uint32_t result = U32(getPhysicalAddress(resultBuffer)); + free(resultBuffer); + return result; +} + int32_t main() { if (!initialized) { initializePci();