Move thread logic to linux/thread.c, rewrite os and idle threads in asm.

This commit is contained in:
2020-05-09 00:50:54 +03:00
parent 96d52454b7
commit dad581883c
3 changed files with 47 additions and 0 deletions

17
linux/pci.c Normal file
View File

@@ -0,0 +1,17 @@
#include <stdio.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
__attribute__((stdcall)) uint32_t pci_read(uint32_t bus, uint32_t dev, uint32_t fun, uint32_t offset, size_t len) {
char path[128];
uint32_t value = 0;
sprintf(path, "/sys/bus/pci/devices/%4.4u:%2.2u:%2.2u.%u/config", 0, bus, dev, fun);
int fd = open(path, O_RDONLY);
lseek(fd, offset, SEEK_SET);
read(fd, &value, len);
close(fd);
return value;
}