refactor into lib/app

This commit is contained in:
Ole Algoritme
2024-03-24 11:18:17 +01:00
parent 372666ec8c
commit b329b7fdd9
11 changed files with 162 additions and 104 deletions

13
app/CMakeLists.txt Normal file
View File

@@ -0,0 +1,13 @@
# ./app/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(gddr6_app)
set(APP_SOURCES src/app.c)
add_executable(gddr6 ${APP_SOURCES})
target_link_libraries(gddr6 PRIVATE gddr6_lib)
target_link_libraries(gddr6 PRIVATE pci)
set_target_properties(gddr6 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

26
app/src/app.c Normal file
View File

@@ -0,0 +1,26 @@
// app.c
#include "gddr6.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
struct device devices[32];
int num_devs = gddr6_detect_compatible_gpus(devices, 32);
if (num_devs == 0) {
printf("No compatible GPU found.\n");
return 1;
}
for (int i = 0; i < num_devs; i++) {
struct device *device = &devices[i];
printf("Device: %s %s (%s / 0x%04x) pci=%x:%x:%x\n", device->name, device->vram,
device->arch, device->dev_id, device->bus, device->dev, device->func);
}
gddr6_initialize();
gddr6_monitor_temperatures(devices, num_devs);
gddr6_cleanup(0);
return 0;
}