Add commands pci_{set,get}_path, add pci config files.

This commit is contained in:
Ivan Baravy 2020-05-20 17:54:58 +03:00
parent 6cc26c6f55
commit b3020947af
69 changed files with 2372 additions and 5042 deletions

View File

@ -4,12 +4,20 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include "pci.h"
char pci_path[PATH_MAX] = ".";
__attribute__((stdcall)) uint32_t pci_read(uint32_t bus, uint32_t dev, uint32_t fun, uint32_t offset, size_t len) {
char path[128];
char path[PATH_MAX*2];
uint32_t value = 0;
sprintf(path, "/sys/bus/pci/devices/%4.4u:%2.2u:%2.2u.%u/config", 0, bus, dev, fun);
sprintf(path, "%s/%4.4u:%2.2u:%2.2u.%u/config", pci_path, 0, bus, dev, fun);
int fd = open(path, O_RDONLY);
if (!fd) {
// TODO: report an error
return UINT32_MAX;
}
lseek(fd, offset, SEEK_SET);
read(fd, &value, len);
close(fd);

8
linux/pci.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef PCI_H_INCLUDED
#define PCI_H_INCLUDED
#include <limits.h>
extern char pci_path[PATH_MAX];
#endif // PCI_H_INCLUDED

25
shell.c
View File

@ -38,6 +38,7 @@
#include "vnet.h"
#include "umka.h"
#include "trace.h"
#include "pci.h"
#include "lodepng.h"
#define PATH_MAX 4096
@ -1117,6 +1118,28 @@ void shell_acpi_get_usage(int argc, char **argv) {
fprintf(fout, "ACPI usage: %" PRIu32 "\n", kos_acpi_usage);
}
void shell_pci_set_path(int argc, char **argv) {
const char *usage = \
"usage: pci_set_path <path>\n"
" path where aaaa:bb:cc.d dirs are";
if (argc != 2) {
puts(usage);
return;
}
strcpy(pci_path, argv[1]);
}
void shell_pci_get_path(int argc, char **argv) {
(void)argv;
const char *usage = \
"usage: pci_get_path";
if (argc != 1) {
puts(usage);
return;
}
fprintf(fout, "pci path: %s\n", pci_path);
}
void shell_stack_init(int argc, char **argv) {
(void)argc;
(void)argv;
@ -1908,6 +1931,8 @@ func_table_t funcs[] = {
{ "bg_put_img", shell_bg_put_img },
{ "bg_map", shell_bg_map },
{ "bg_unmap", shell_bg_unmap },
{ "pci_set_path", shell_pci_set_path },
{ "pci_get_path", shell_pci_get_path },
{ NULL, NULL },
};

View File

@ -1,3 +1,6 @@
/> pci_set_path machines/000/pci
/> acpi_set_usage 2
/> acpi_preload_table machines/000/acpi/DSDT
table #0
/> acpi_preload_table machines/000/acpi/SSDT1
@ -12,6 +15,7 @@ table #4
table #5
/> acpi_preload_table machines/000/acpi/SSDT6
table #6
/> acpi_enable
acpi.aml.process_table begin
table length 0x00013C50

View File

@ -1,3 +1,6 @@
pci_set_path machines/000/pci
acpi_set_usage 2
acpi_preload_table machines/000/acpi/DSDT
acpi_preload_table machines/000/acpi/SSDT1
acpi_preload_table machines/000/acpi/SSDT2
@ -5,4 +8,5 @@ acpi_preload_table machines/000/acpi/SSDT3
acpi_preload_table machines/000/acpi/SSDT4
acpi_preload_table machines/000/acpi/SSDT5
acpi_preload_table machines/000/acpi/SSDT6
acpi_enable

View File

@ -1,9 +1,13 @@
/> pci_set_path machines/001/pci
/> acpi_set_usage 2
/> acpi_preload_table machines/001/acpi/DSDT
table #0
/> acpi_preload_table machines/001/acpi/SSDT1
table #1
/> acpi_preload_table machines/001/acpi/SSDT2
table #2
/> acpi_enable
acpi.aml.process_table begin
table length 0x0000CFFB
@ -73791,623 +73795,6 @@ aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_PRT'
tree name: 'VGA_'
scope name: 'VGA_'
aml._.name_to_node end
aml._.get_node_by_name end
acpi.call_node begin
# func name _PRT
# bytes 0x49500AA0
# bytes 0x41A44D43
# bytes 0xA4303052
table/position: [0xFFFF426E]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.named_obj end
aml._.object end
aml._.if begin
pkg_length: 0x0000000A
aml._.term_arg begin
aml._.name_string begin
aml._.name_string begin again
offset: 0xFFFF4270
aml._.name_path begin
aml._.name_path end
name_string: PICM
aml._.name_string end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: 'PICM'
tree name: 'root'
scope name: 'root'
no such node
aml._.name_to_node end
aml._.name_to_node begin
name: 'PICM'
tree name: 'root'
scope name: '_PRT'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.data_object begin
aml._.data_object end
aml._.name_string begin
aml._.name_string begin again
offset: 0xFFFF4270
aml._.name_path begin
aml._.name_path end
name_string: PICM
aml._.name_string end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: 'PICM'
tree name: 'root'
scope name: 'root'
no such node
aml._.name_to_node end
aml._.name_to_node begin
name: 'PICM'
tree name: 'root'
scope name: '_PRT'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.term_arg end
aml._.cast begin
types 2 to 2
aml._.cast.integer_to_integer begin
aml._.cast.integer_to_integer end
aml._.cast end
if branch taken
table/position: [0xFFFF4274]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.named_obj end
aml._.object end
aml._.return begin
aml._.term_arg begin
aml._.name_string begin
aml._.name_string begin again
offset: 0xFFFF4275
aml._.name_path begin
aml._.name_path end
name_string: AR00
aml._.name_string end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: 'AR00'
tree name: 'root'
scope name: 'root'
no such node
aml._.name_to_node end
aml._.name_to_node begin
name: 'AR00'
tree name: 'root'
scope name: '_PRT'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.data_object begin
aml._.data_object end
aml._.name_string begin
aml._.name_string begin again
offset: 0xFFFF4275
aml._.name_path begin
aml._.name_path end
name_string: AR00
aml._.name_string end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: 'AR00'
tree name: 'root'
scope name: 'root'
no such node
aml._.name_to_node end
aml._.name_to_node begin
name: 'AR00'
tree name: 'root'
scope name: '_PRT'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.term_arg end
aml._.return end
acpi.call_node end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATC4'
scope name: 'ATC4'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATC3'
scope name: 'ATC3'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATC2'
scope name: 'ATC2'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATC1'
scope name: 'ATC1'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATC0'
scope name: 'ATC0'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATCS'
scope name: 'ATCS'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AT01'
scope name: 'AT01'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AT00'
scope name: 'AT00'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PX09'
scope name: 'PX09'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PX08'
scope name: 'PX08'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PX04'
scope name: 'PX04'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PX03'
scope name: 'PX03'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PX02'
scope name: 'PX02'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PX01'
scope name: 'PX01'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PX00'
scope name: 'PX00'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATPX'
scope name: 'ATPX'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT9'
scope name: 'CNT9'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT8'
scope name: 'CNT8'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT7'
scope name: 'CNT7'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT6'
scope name: 'CNT6'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT5'
scope name: 'CNT5'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT4'
scope name: 'CNT4'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT3'
scope name: 'CNT3'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT2'
scope name: 'CNT2'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT1'
scope name: 'CNT1'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'CNT0'
scope name: 'CNT0'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'HSID'
scope name: 'HSID'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'DSID'
scope name: 'DSID'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATPB'
scope name: 'ATPB'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'XTRM'
scope name: 'XTRM'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'TVGA'
scope name: 'TVGA'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'VROM'
scope name: 'VROM'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'SROM'
scope name: 'SROM'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'REVD'
scope name: 'REVD'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AF15'
scope name: 'AF15'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AFN7'
scope name: 'AFN7'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AFN6'
scope name: 'AFN6'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AFN5'
scope name: 'AFN5'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AFN4'
scope name: 'AFN4'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AFN3'
scope name: 'AFN3'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AFN0'
scope name: 'AFN0'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AF03'
scope name: 'AF03'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AF02'
scope name: 'AF02'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'SACT'
scope name: 'SACT'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'SCDY'
scope name: 'SCDY'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'SSDM'
scope name: 'SSDM'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'SSPS'
scope name: 'SSPS'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'SFPI'
scope name: 'SFPI'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'SFPG'
scope name: 'SFPG'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'STHI'
scope name: 'STHI'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'STHG'
scope name: 'STHG'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'SEXM'
scope name: 'SEXM'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'MSKN'
scope name: 'MSKN'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PSBR'
scope name: 'PSBR'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AF01'
scope name: 'AF01'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AF00'
scope name: 'AF00'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATIF'
scope name: 'ATIF'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'ATIB'
scope name: 'ATIB'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'LCD_'
scope name: 'LCD_'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: '_DOD'
scope name: '_DOD'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: '_DOS'
scope name: '_DOS'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'DOSA'
scope name: 'DOSA'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: '_STA'
scope name: '_STA'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'AF7E'
scope name: 'AF7E'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PXDY'
scope name: 'PXDY'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PXFX'
scope name: 'PXFX'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PXMX'
scope name: 'PXMX'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PXID'
scope name: 'PXID'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: 'PXEN'
scope name: 'PXEN'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: '_ADR'
scope name: '_ADR'
aml._.name_to_node end
aml._.get_node_by_name end
aml._.get_node_by_name begin
aml._.name_to_node begin
name: '_ADR'
tree name: '_PRT'
scope name: '_PRT'
@ -74707,4 +74094,4 @@ tree name: '_HID'
scope name: '_HID'
aml._.name_to_node end
aml._.get_node_by_name end
Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device
Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device Device DUMP 00:01.0 1002:990D 11

View File

@ -1,4 +1,8 @@
pci_set_path machines/001/pci
acpi_set_usage 2
acpi_preload_table machines/001/acpi/DSDT
acpi_preload_table machines/001/acpi/SSDT1
acpi_preload_table machines/001/acpi/SSDT2
acpi_enable

View File

@ -1,3 +1,6 @@
pci_set_path machines/002/pci
acpi_set_usage 2
acpi_preload_table machines/002/acpi/DSDT
acpi_preload_table machines/002/acpi/SSDT1
acpi_preload_table machines/002/acpi/SSDT2
@ -11,4 +14,5 @@ acpi_preload_table machines/002/acpi/SSDT9
acpi_preload_table machines/002/acpi/SSDT10
acpi_preload_table machines/002/acpi/SSDT11
acpi_preload_table machines/002/acpi/SSDT12
acpi_enable

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,6 @@
pci_set_path machines/003/pci
acpi_set_usage 2
acpi_preload_table machines/003/acpi/DSDT
acpi_enable

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,8 @@
acpi_set_usage 1
acpi_preload_table machines/004/acpi/DSDT
acpi_preload_table machines/004/acpi/SSDT1
acpi_preload_table machines/004/acpi/SSDT2
acpi_preload_table machines/004/acpi/SSDT3
acpi_enable

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.