Implement and export more acpi wrappers.
This commit is contained in:
parent
18c6f4922c
commit
2f8181504c
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@ umka_shell
|
||||
umka_fuse
|
||||
umka_os
|
||||
umka_ping
|
||||
umka_gen_devices_dat
|
||||
mkdirrange
|
||||
mkfilepattern
|
||||
lfbviewx
|
||||
|
14
makefile
14
makefile
@ -11,8 +11,8 @@ CFLAGS_32=$(CFLAGS) -m32
|
||||
LDFLAGS=-no-pie
|
||||
LDFLAGS_32=$(LDFLAGS) -m32
|
||||
|
||||
all: umka_shell umka_fuse umka_os umka.sym umka.prp umka.lst tags \
|
||||
covpreproc default.skn skin.skn
|
||||
all: umka_shell umka_fuse umka_os umka_gen_devices_dat umka.sym umka.prp \
|
||||
umka.lst tags covpreproc default.skn skin.skn
|
||||
|
||||
covpreproc: covpreproc.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
|
||||
@ -28,6 +28,9 @@ umka_os: umka_os.o umka.o shell.o lodepng.o vdisk.o vnet.o trace.o trace_lbr.o \
|
||||
pci.o thread.o umka_ping.o
|
||||
$(CC) $(LDFLAGS_32) $^ -o $@ -static -T umka.ld
|
||||
|
||||
umka_gen_devices_dat: umka_gen_devices_dat.o umka.o pci.o thread.o
|
||||
$(CC) $(LDFLAGS_32) $^ -o $@ -static -T umka.ld
|
||||
|
||||
umka.o umka.fas: umka.asm
|
||||
INCLUDE="$(KOLIBRIOS)/kernel/trunk;$(KOLIBRIOS)/programs/develop/libraries/libcrash/hash" \
|
||||
$(FASM) $< umka.o -s umka.fas -m 1234567
|
||||
@ -83,11 +86,14 @@ umka_fuse.o: umka_fuse.c umka.h
|
||||
umka_os.o: umka_os.c umka.h
|
||||
$(CC) $(CFLAGS_32) -c $< -D_XOPEN_SOURCE=600
|
||||
|
||||
umka_gen_devices_dat.o: umka_gen_devices_dat.c umka.h
|
||||
$(CC) $(CFLAGS_32) -c $<
|
||||
|
||||
umka_ping.o: umka_ping.c umka.h
|
||||
$(CC) $(CFLAGS_32) -D_DEFAULT_SOURCE -c $<
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
clean:
|
||||
rm -f *.o umka_shell umka_fuse umka_os umka.fas umka.sym umka.lst umka.prp \
|
||||
coverage
|
||||
rm -f *.o umka_shell umka_fuse umka_os umka_gen_devices_dat umka.fas \
|
||||
umka.sym umka.lst umka.prp coverage
|
||||
|
11
umka.asm
11
umka.asm
@ -77,6 +77,17 @@ public net_buff_alloc as 'kos_net_buff_alloc'
|
||||
public mem_block_list
|
||||
public pci_root
|
||||
|
||||
public acpi.aml.init as "kos_acpi_aml_init"
|
||||
public acpi_root as "kos_acpi_root"
|
||||
public aml._.attach as "kos_aml_attach"
|
||||
public acpi.fill_pci_irqs as "kos_acpi_fill_pci_irqs"
|
||||
public acpi.aml.new_thread as "kos_acpi_aml_new_thread"
|
||||
public aml._.alloc_node as "kos_aml_alloc_node"
|
||||
public aml._.constructor.integer as "kos_aml_constructor_integer"
|
||||
public aml._.constructor.package as "kos_aml_constructor_package"
|
||||
public acpi._.lookup_node as "kos_acpi_lookup_node"
|
||||
public acpi._.print_tree as "kos_acpi_print_tree"
|
||||
|
||||
public window._.set_screen as 'kos_window_set_screen'
|
||||
public _display as 'kos_display'
|
||||
|
||||
|
114
umka.h
114
umka.h
@ -2,11 +2,10 @@
|
||||
#define UMKA_H_INCLUDED
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <signal.h>
|
||||
#include <signal.h> // for irq0: siginfo_t
|
||||
|
||||
#define STDCALL __attribute__((__stdcall__))
|
||||
|
||||
#define BDFE_LEN_CP866 304
|
||||
#define BDFE_LEN_UNICODE 560
|
||||
@ -139,19 +138,16 @@ typedef struct disk_t disk_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t strucsize;
|
||||
__attribute__((__stdcall__)) void (*close)(void *userdata);
|
||||
__attribute__((__stdcall__)) void (*closemedia)(void *userdata);
|
||||
__attribute__((__stdcall__)) int (*querymedia)(void *userdata,
|
||||
diskmediainfo_t *info);
|
||||
__attribute__((__stdcall__)) int (*read)(void *userdata, void *buffer,
|
||||
off_t startsector,
|
||||
size_t *numsectors);
|
||||
__attribute__((__stdcall__)) int (*write)(void *userdata, void *buffer,
|
||||
off_t startsector,
|
||||
size_t *numsectors);
|
||||
__attribute__((__stdcall__)) int (*flush)(void *userdata);
|
||||
__attribute__((__stdcall__)) unsigned int
|
||||
(*adjust_cache_size)(void *userdata, size_t suggested_size);
|
||||
STDCALL void (*close)(void *userdata);
|
||||
STDCALL void (*closemedia)(void *userdata);
|
||||
STDCALL int (*querymedia)(void *userdata, diskmediainfo_t *info);
|
||||
STDCALL int (*read)(void *userdata, void *buffer, off_t startsector,
|
||||
size_t *numsectors);
|
||||
STDCALL int (*write)(void *userdata, void *buffer, off_t startsector,
|
||||
size_t *numsectors);
|
||||
STDCALL int (*flush)(void *userdata);
|
||||
STDCALL unsigned int (*adjust_cache_size)(void *userdata,
|
||||
size_t suggested_size);
|
||||
} diskfunc_t;
|
||||
|
||||
struct disk_t {
|
||||
@ -353,9 +349,9 @@ struct net_device_t {
|
||||
char *name; // ptr to 0 terminated string
|
||||
|
||||
// ptrs to driver functions
|
||||
__attribute__((__stdcall__)) void (*unload) (void);
|
||||
__attribute__((__stdcall__)) void (*reset) (void);
|
||||
__attribute__((__stdcall__)) int (*transmit) (net_buff_t *);
|
||||
STDCALL void (*unload) (void);
|
||||
STDCALL void (*reset) (void);
|
||||
STDCALL int (*transmit) (net_buff_t *);
|
||||
|
||||
uint64_t bytes_tx; // statistics, updated by the driver
|
||||
uint64_t bytes_rx;
|
||||
@ -376,6 +372,27 @@ typedef struct {
|
||||
uint16_t ttl;
|
||||
} arp_entry_t;
|
||||
|
||||
typedef struct acpi_node acpi_node_t;
|
||||
struct acpi_node {
|
||||
uint32_t name;
|
||||
int32_t refcount;
|
||||
acpi_node_t *parent;
|
||||
acpi_node_t *children;
|
||||
acpi_node_t *next;
|
||||
int32_t type;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
acpi_node_t node;
|
||||
uint64_t value;
|
||||
} kos_node_integer_t;
|
||||
|
||||
typedef struct {
|
||||
acpi_node_t node;
|
||||
acpi_node_t **list;
|
||||
size_t el_cnt;
|
||||
} kos_node_package_t;
|
||||
|
||||
__attribute__((__noreturn__)) void
|
||||
kos_osloop(void);
|
||||
|
||||
@ -391,13 +408,13 @@ i40(void);
|
||||
uint32_t
|
||||
kos_time_to_epoch(uint32_t *time);
|
||||
|
||||
__attribute__((__stdcall__)) disk_t *
|
||||
STDCALL disk_t *
|
||||
disk_add(diskfunc_t *disk, const char *name, void *userdata, uint32_t flags);
|
||||
|
||||
__attribute__((__stdcall__)) void *
|
||||
STDCALL void *
|
||||
disk_media_changed(diskfunc_t *disk, int inserted);
|
||||
|
||||
__attribute__((__stdcall__)) void
|
||||
STDCALL void
|
||||
disk_del(disk_t *disk);
|
||||
|
||||
void
|
||||
@ -413,7 +430,7 @@ extern uint8_t kos_ramdisk[2880*512];
|
||||
disk_t *
|
||||
kos_ramdisk_init(void);
|
||||
|
||||
__attribute__((__stdcall__)) void
|
||||
STDCALL void
|
||||
kos_set_mouse_data(uint32_t btn_state, int32_t xmoving, int32_t ymoving,
|
||||
int32_t vscroll, int32_t hscroll);
|
||||
|
||||
@ -425,7 +442,7 @@ umka_mouse_move(int lbheld, int mbheld, int rbheld, int xabs, int32_t xmoving,
|
||||
kos_set_mouse_data(btn_state, xmoving, ymoving, vscroll, hscroll);
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__)) net_buff_t *
|
||||
STDCALL net_buff_t *
|
||||
kos_net_buff_alloc(size_t size);
|
||||
|
||||
static inline size_t
|
||||
@ -471,6 +488,49 @@ kos_acpi_call_name(void *ctx, const char *name) {
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
#define KOS_ACPI_NODE_Uninitialized 1
|
||||
#define KOS_ACPI_NODE_Integer 2
|
||||
#define KOS_ACPI_NODE_String 3
|
||||
#define KOS_ACPI_NODE_Buffer 4
|
||||
#define KOS_ACPI_NODE_Package 5
|
||||
#define KOS_ACPI_NODE_OpRegionField 6
|
||||
#define KOS_ACPI_NODE_IndexField 7
|
||||
#define KOS_ACPI_NODE_BankField 8
|
||||
#define KOS_ACPI_NODE_Device 9
|
||||
|
||||
extern acpi_node_t *kos_acpi_root;
|
||||
|
||||
typedef struct {
|
||||
int pew[0x100];
|
||||
} amlctx_t;
|
||||
|
||||
void
|
||||
kos_acpi_aml_init();
|
||||
|
||||
STDCALL void
|
||||
kos_aml_attach(acpi_node_t *parent, acpi_node_t *node);
|
||||
|
||||
STDCALL void
|
||||
kos_acpi_fill_pci_irqs(void *ctx);
|
||||
|
||||
STDCALL amlctx_t*
|
||||
kos_acpi_aml_new_thread();
|
||||
|
||||
STDCALL acpi_node_t*
|
||||
kos_aml_alloc_node(int32_t type);
|
||||
|
||||
STDCALL acpi_node_t*
|
||||
kos_aml_constructor_integer(void);
|
||||
|
||||
STDCALL acpi_node_t*
|
||||
kos_aml_constructor_package(size_t el_cnt);
|
||||
|
||||
STDCALL acpi_node_t*
|
||||
kos_acpi_lookup_node(acpi_node_t *root, char *name);
|
||||
|
||||
STDCALL void
|
||||
kos_acpi_print_tree(void *ctx);
|
||||
|
||||
typedef struct {
|
||||
uint32_t value;
|
||||
uint32_t errorcode;
|
||||
@ -504,7 +564,7 @@ kos_net_add_device(net_device_t *dev) {
|
||||
return dev_num;
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__)) void
|
||||
STDCALL void
|
||||
kos_window_set_screen(ssize_t left, ssize_t top, ssize_t right, ssize_t bottom,
|
||||
ssize_t proc);
|
||||
|
||||
@ -762,7 +822,7 @@ extern void *acpi_ctx;
|
||||
extern uint32_t kos_acpi_usage;
|
||||
extern uint32_t kos_acpi_node_alloc_cnt;
|
||||
extern uint32_t kos_acpi_node_free_cnt;
|
||||
extern uint32_t kos_acpi_count_nodes(void *ctx) __attribute__((__stdcall__));
|
||||
extern uint32_t kos_acpi_count_nodes(void *ctx) STDCALL;
|
||||
extern disk_t disk_list;
|
||||
|
||||
static inline void
|
||||
|
@ -35,6 +35,9 @@
|
||||
#include "vdisk.h"
|
||||
#include "umka.h"
|
||||
|
||||
#define UMKA_DEFAULT_DISPLAY_WIDTH 400
|
||||
#define UMKA_DEFAULT_DISPLAY_HEIGHT 300
|
||||
|
||||
#define DIRENTS_TO_READ 100
|
||||
|
||||
static void
|
||||
@ -151,6 +154,12 @@ main(int argc, char *argv[]) {
|
||||
printf("usage: umka_fuse dir img\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
kos_boot.bpp = 32;
|
||||
kos_boot.x_res = UMKA_DEFAULT_DISPLAY_WIDTH;
|
||||
kos_boot.y_res = UMKA_DEFAULT_DISPLAY_HEIGHT;
|
||||
kos_boot.pitch = UMKA_DEFAULT_DISPLAY_WIDTH*4; // 32bpp
|
||||
|
||||
umka_init();
|
||||
void *userdata = vdisk_init(argv[2], 1, 0u);
|
||||
void *vdisk = disk_add(&vdisk_functions, "hd0", userdata, 0);
|
||||
|
27
umka_os.c
27
umka_os.c
@ -1,3 +1,22 @@
|
||||
/*
|
||||
UMKa - User-Mode KolibriOS developer tools
|
||||
umka_os - kind of KolibriOS rump kernel
|
||||
Copyright (C) 2018--2021 Ivan Baravy <dunkaist@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
@ -13,6 +32,9 @@
|
||||
#include "shell.h"
|
||||
#include "trace.h"
|
||||
|
||||
#define UMKA_DEFAULT_DISPLAY_WIDTH 400
|
||||
#define UMKA_DEFAULT_DISPLAY_HEIGHT 300
|
||||
|
||||
#define THREAD_STACK_SIZE 0x100000
|
||||
|
||||
static void
|
||||
@ -104,6 +126,11 @@ main() {
|
||||
*/
|
||||
printf("pid=%d, kos_lfb_base=%p\n", getpid(), (void*)kos_lfb_base);
|
||||
|
||||
kos_boot.bpp = 32;
|
||||
kos_boot.x_res = UMKA_DEFAULT_DISPLAY_WIDTH;
|
||||
kos_boot.y_res = UMKA_DEFAULT_DISPLAY_HEIGHT;
|
||||
kos_boot.pitch = UMKA_DEFAULT_DISPLAY_WIDTH*4; // 32bpp
|
||||
|
||||
umka_init();
|
||||
umka_stack_init();
|
||||
|
||||
|
20
vdisk.c
20
vdisk.c
@ -37,8 +37,8 @@ void *vdisk_init(const char *fname, int adjust_cache_size, size_t cache_size) {
|
||||
return vdisk;
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
void vdisk_close(void *userdata) {
|
||||
STDCALL void
|
||||
vdisk_close(void *userdata) {
|
||||
COVERAGE_OFF();
|
||||
vdisk_t *vdisk = userdata;
|
||||
fclose(vdisk->file);
|
||||
@ -46,8 +46,8 @@ void vdisk_close(void *userdata) {
|
||||
COVERAGE_ON();
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
int vdisk_read(void *userdata, void *buffer, off_t startsector,
|
||||
STDCALL int
|
||||
vdisk_read(void *userdata, void *buffer, off_t startsector,
|
||||
size_t *numsectors) {
|
||||
COVERAGE_OFF();
|
||||
vdisk_t *vdisk = userdata;
|
||||
@ -57,8 +57,8 @@ int vdisk_read(void *userdata, void *buffer, off_t startsector,
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
int vdisk_write(void *userdata, void *buffer, off_t startsector,
|
||||
STDCALL int
|
||||
vdisk_write(void *userdata, void *buffer, off_t startsector,
|
||||
size_t *numsectors) {
|
||||
COVERAGE_OFF();
|
||||
vdisk_t *vdisk = userdata;
|
||||
@ -68,8 +68,8 @@ int vdisk_write(void *userdata, void *buffer, off_t startsector,
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
int vdisk_querymedia(void *userdata, diskmediainfo_t *minfo) {
|
||||
STDCALL int
|
||||
vdisk_querymedia(void *userdata, diskmediainfo_t *minfo) {
|
||||
COVERAGE_OFF();
|
||||
vdisk_t *vdisk = userdata;
|
||||
minfo->flags = 0u;
|
||||
@ -79,8 +79,8 @@ int vdisk_querymedia(void *userdata, diskmediainfo_t *minfo) {
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
size_t vdisk_adjust_cache_size(void *userdata, size_t suggested_size) {
|
||||
STDCALL size_t
|
||||
vdisk_adjust_cache_size(void *userdata, size_t suggested_size) {
|
||||
vdisk_t *vdisk = userdata;
|
||||
if (vdisk->adjust_cache_size) {
|
||||
return vdisk->cache_size;
|
||||
|
23
vdisk.h
23
vdisk.h
@ -7,22 +7,21 @@
|
||||
|
||||
void *vdisk_init(const char *fname, int adjust_cache_size, size_t cache_size);
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
void vdisk_close(void *userdata);
|
||||
STDCALL void
|
||||
vdisk_close(void *userdata);
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
int vdisk_read(void *userdata, void *buffer, off_t startsector,
|
||||
size_t *numsectors);
|
||||
STDCALL int
|
||||
vdisk_read(void *userdata, void *buffer, off_t startsector, size_t *numsectors);
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
int vdisk_write(void *userdata, void *buffer, off_t startsector,
|
||||
size_t *numsectors);
|
||||
STDCALL int
|
||||
vdisk_write(void *userdata, void *buffer, off_t startsector,
|
||||
size_t *numsectors);
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
int vdisk_querymedia(void *userdata, diskmediainfo_t *minfo);
|
||||
STDCALL int
|
||||
vdisk_querymedia(void *userdata, diskmediainfo_t *minfo);
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
unsigned int vdisk_adjust_cache_size(void *userdata, unsigned suggested_size);
|
||||
STDCALL unsigned int
|
||||
vdisk_adjust_cache_size(void *userdata, unsigned suggested_size);
|
||||
|
||||
extern diskfunc_t vdisk_functions;
|
||||
|
||||
|
12
vnet.c
12
vnet.c
@ -42,15 +42,15 @@ net_device_t *vnet_init(int fd) {
|
||||
return vnet;
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
void vnet_unload() {
|
||||
STDCALL void
|
||||
vnet_unload() {
|
||||
printf("vnet_unload\n");
|
||||
COVERAGE_OFF();
|
||||
COVERAGE_ON();
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
void vnet_reset() {
|
||||
STDCALL void
|
||||
vnet_reset() {
|
||||
printf("vnet_reset\n");
|
||||
COVERAGE_OFF();
|
||||
COVERAGE_ON();
|
||||
@ -63,8 +63,8 @@ static void dump_net_buff(net_buff_t *buf) {
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
int vnet_transmit(net_buff_t *buf) {
|
||||
STDCALL int
|
||||
vnet_transmit(net_buff_t *buf) {
|
||||
net_device_t *vnet;
|
||||
__asm__ __inline__ __volatile__ (
|
||||
"nop"
|
||||
|
15
vnet.h
15
vnet.h
@ -7,15 +7,16 @@
|
||||
|
||||
net_device_t *vnet_init(int fd);
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
void vnet_unload(void);
|
||||
STDCALL void
|
||||
vnet_unload(void);
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
void vnet_reset(void);
|
||||
STDCALL void
|
||||
vnet_reset(void);
|
||||
|
||||
__attribute__((__stdcall__))
|
||||
int vnet_transmit(net_buff_t *buf);
|
||||
STDCALL int
|
||||
vnet_transmit(net_buff_t *buf);
|
||||
|
||||
void vnet_receive_frame(net_device_t *dev, void *data, size_t size);
|
||||
void
|
||||
vnet_receive_frame(net_device_t *dev, void *data, size_t size);
|
||||
|
||||
#endif // VNET_H_INCLUDED
|
||||
|
Loading…
Reference in New Issue
Block a user