Merge kolibri.h and syscalls.h, rename kolibri.h to umka.h.
This commit is contained in:
parent
cea3923666
commit
5d99380431
377
kolibri.h
377
kolibri.h
@ -1,377 +0,0 @@
|
||||
#ifndef KOLIBRI_H_INCLUDED
|
||||
#define KOLIBRI_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define BDFE_LEN_CP866 304
|
||||
#define BDFE_LEN_UNICODE 560
|
||||
|
||||
typedef struct {
|
||||
uint32_t left, top, right, bottom;
|
||||
} rect_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t left, top, width, height;
|
||||
} box_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t cpu_usage;
|
||||
uint16_t window_stack_position;
|
||||
uint16_t window_stack_value;
|
||||
uint16_t pad;
|
||||
char process_name[12];
|
||||
uint32_t memory_start;
|
||||
uint32_t used_memory;
|
||||
uint32_t pid;
|
||||
box_t box;
|
||||
uint16_t slot_state;
|
||||
uint16_t pad2;
|
||||
box_t client_box;
|
||||
uint8_t wnd_state;
|
||||
uint8_t pad3[1024-71];
|
||||
} __attribute__((packed)) process_information_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t frame, grab, work_3d_dark, work_3d_light, grab_text, work,
|
||||
work_button, work_button_text, work_text, work_graph;
|
||||
} system_colors_t;
|
||||
|
||||
typedef enum {
|
||||
DEFAULT_ENCODING,
|
||||
CP866,
|
||||
UTF16,
|
||||
UTF8,
|
||||
INVALID_ENCODING,
|
||||
} fs_enc_t;
|
||||
|
||||
typedef enum {
|
||||
F70 = 70,
|
||||
F80 = 80,
|
||||
} f70or80_t;
|
||||
|
||||
enum {
|
||||
ERROR_SUCCESS,
|
||||
ERROR_DISK_BASE,
|
||||
ERROR_UNSUPPORTED_FS,
|
||||
ERROR_UNKNOWN_FS,
|
||||
ERROR_PARTITION,
|
||||
ERROR_FILE_NOT_FOUND,
|
||||
ERROR_END_OF_FILE,
|
||||
ERROR_MEMORY_POINTER,
|
||||
ERROR_DISK_FULL,
|
||||
ERROR_FS_FAIL,
|
||||
ERROR_ACCESS_DENIED,
|
||||
ERROR_DEVICE,
|
||||
ERROR_OUT_OF_MEMORY,
|
||||
};
|
||||
|
||||
typedef struct lhead lhead_t;
|
||||
|
||||
struct lhead {
|
||||
lhead_t *next;
|
||||
lhead_t *prev;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
lhead_t wait_list;
|
||||
uint32_t count;
|
||||
} mutex_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t flags;
|
||||
uint32_t sector_size;
|
||||
uint64_t capacity; // in sectors
|
||||
} diskmediainfo_t;
|
||||
|
||||
typedef struct {
|
||||
uintptr_t pointer;
|
||||
uint32_t data_size;
|
||||
uintptr_t data;
|
||||
uint32_t sad_size;
|
||||
uint32_t search_start;
|
||||
uint32_t sector_size_log;
|
||||
} disk_cache_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t first_sector;
|
||||
uint64_t length; // in sectors
|
||||
void *disk;
|
||||
void *fs_user_functions;
|
||||
} partition_t;
|
||||
|
||||
typedef struct disk_t disk_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t strucsize;
|
||||
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) __attribute__((__stdcall__));
|
||||
} diskfunc_t;
|
||||
|
||||
struct disk_t {
|
||||
disk_t *next;
|
||||
disk_t *prev;
|
||||
diskfunc_t *functions;
|
||||
const char *name;
|
||||
void *userdata;
|
||||
uint32_t driver_flags;
|
||||
uint32_t ref_count;
|
||||
mutex_t media_lock;
|
||||
uint8_t media_inserted;
|
||||
uint8_t media_used;
|
||||
uint16_t padding;
|
||||
uint32_t media_ref_count;
|
||||
diskmediainfo_t media_info;
|
||||
uint32_t num_partitions;
|
||||
partition_t **partitions;
|
||||
uint32_t cache_size;
|
||||
mutex_t cache_lock;
|
||||
disk_cache_t sys_cache;
|
||||
disk_cache_t app_cache;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t attr;
|
||||
uint32_t enc;
|
||||
uint32_t ctime;
|
||||
uint32_t cdate;
|
||||
uint32_t atime;
|
||||
uint32_t adate;
|
||||
uint32_t mtime;
|
||||
uint32_t mdate;
|
||||
uint64_t size;
|
||||
char name[0];
|
||||
} bdfe_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t status;
|
||||
uint32_t count;
|
||||
} f7080ret_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t sf;
|
||||
uint64_t offset;
|
||||
uint32_t count;
|
||||
void *buf;
|
||||
union {
|
||||
struct {
|
||||
uint8_t zero;
|
||||
const char *path;
|
||||
} __attribute__((packed)) f70;
|
||||
struct {
|
||||
uint32_t path_encoding;
|
||||
const char *path;
|
||||
} f80;
|
||||
} u;
|
||||
} __attribute__((packed)) f7080s0arg_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t sf;
|
||||
uint32_t offset;
|
||||
uint32_t encoding;
|
||||
uint32_t size;
|
||||
void *buf;
|
||||
union {
|
||||
struct {
|
||||
uint8_t zero;
|
||||
const char *path;
|
||||
} __attribute__((packed)) f70;
|
||||
struct {
|
||||
uint32_t path_encoding;
|
||||
const char *path;
|
||||
} f80;
|
||||
} u;
|
||||
} __attribute__((packed)) f7080s1arg_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t version;
|
||||
uint32_t cnt;
|
||||
uint32_t total_cnt;
|
||||
uint32_t zeroed[5];
|
||||
bdfe_t bdfes[0];
|
||||
} f7080s1info_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t sf;
|
||||
uint32_t reserved1;
|
||||
uint32_t flags;
|
||||
uint32_t reserved2;
|
||||
void *buf;
|
||||
union {
|
||||
struct {
|
||||
uint8_t zero;
|
||||
const char *path;
|
||||
} __attribute__((packed)) f70;
|
||||
struct {
|
||||
uint32_t path_encoding;
|
||||
const char *path;
|
||||
} f80;
|
||||
} u;
|
||||
} __attribute__((packed)) f7080s5arg_t;
|
||||
|
||||
#define KF_READONLY 0x01
|
||||
#define KF_HIDDEN 0x02
|
||||
#define KF_SYSTEM 0x04
|
||||
#define KF_LABEL 0x08
|
||||
#define KF_FOLDER 0x10
|
||||
#define KF_ATTR_CNT 5
|
||||
|
||||
#define HASH_SIZE 32
|
||||
typedef struct {
|
||||
uint8_t hash[HASH_SIZE];
|
||||
uint8_t opaque[1024-HASH_SIZE];
|
||||
} hash_context;
|
||||
|
||||
typedef struct {
|
||||
uint32_t edi;
|
||||
uint32_t esi;
|
||||
uint32_t ebp;
|
||||
uint32_t esp;
|
||||
uint32_t ebx;
|
||||
uint32_t edx;
|
||||
uint32_t ecx;
|
||||
uint32_t eax;
|
||||
} pushad_t;
|
||||
|
||||
#define NET_TYPE_ETH 1
|
||||
#define NET_TYPE_SLIP 2
|
||||
|
||||
// Link state
|
||||
#define ETH_LINK_DOWN 0x0 // Link is down
|
||||
#define ETH_LINK_UNKNOWN 0x1 // There could be an active link
|
||||
#define ETH_LINK_FD 0x2 // full duplex flag
|
||||
#define ETH_LINK_10M 0x4 // 10 mbit
|
||||
#define ETH_LINK_100M 0x8 // 100 mbit
|
||||
#define ETH_LINK_1G 0xc // gigabit
|
||||
|
||||
// Ethernet protocol numbers
|
||||
#define ETHER_PROTO_ARP 0x0608
|
||||
#define ETHER_PROTO_IPv4 0x0008
|
||||
#define ETHER_PROTO_IPv6 0xDD86
|
||||
#define ETHER_PROTO_PPP_DISCOVERY 0x6388
|
||||
#define ETHER_PROTO_PPP_SESSION 0x6488
|
||||
|
||||
// Internet protocol numbers
|
||||
#define IP_PROTO_IP 0
|
||||
#define IP_PROTO_ICMP 1
|
||||
#define IP_PROTO_TCP 6
|
||||
#define IP_PROTO_UDP 17
|
||||
#define IP_PROTO_RAW 255
|
||||
|
||||
// IP options
|
||||
#define IP_TOS 1
|
||||
#define IP_TTL 2
|
||||
#define IP_HDRINCL 3
|
||||
|
||||
// PPP protocol numbers
|
||||
#define PPP_PROTO_IPv4 0x2100
|
||||
#define PPP_PROTO_IPV6 0x5780
|
||||
#define PPP_PROTO_ETHERNET 666
|
||||
|
||||
// Protocol family
|
||||
#define AF_INET4 AF_INET
|
||||
|
||||
typedef struct {
|
||||
uint32_t device_type; // type field
|
||||
uint32_t mtu; // Maximal Transmission Unit
|
||||
char *name; // ptr to 0 terminated string
|
||||
|
||||
void *unload; // ptrs to driver functions
|
||||
void *reset;
|
||||
void *transmit;
|
||||
|
||||
uint64_t bytes_tx; // statistics, updated by the driver
|
||||
uint64_t bytes_rx;
|
||||
uint32_t packets_tx;
|
||||
uint32_t packets_rx;
|
||||
|
||||
uint32_t link_state; // link state (0 = no link)
|
||||
uint32_t hwacc; // bitmask stating enabled HW accelerations (offload
|
||||
// engines)
|
||||
uint8_t mac[6];
|
||||
} net_device_t; // NET_DEVICE
|
||||
|
||||
typedef struct {
|
||||
void *next; // pointer to next frame in list
|
||||
void *prev; // pointer to previous frame in list
|
||||
net_device_t *device; // ptr to NET_DEVICE structure
|
||||
uint32_t type; // encapsulation type: e.g. Ethernet
|
||||
size_t length; // size of encapsulated data
|
||||
size_t offset; // offset to actual data (24 bytes for default frame)
|
||||
uint8_t data[0];
|
||||
} net_buff_t;
|
||||
|
||||
void kos_init(void);
|
||||
void i40(void);
|
||||
uint32_t kos_time_to_epoch(uint32_t *time);
|
||||
|
||||
void *disk_add(diskfunc_t *disk, const char *name, void *userdata, uint32_t flags) __attribute__((__stdcall__));
|
||||
void *disk_media_changed(diskfunc_t *disk, int inserted) __attribute__((__stdcall__));
|
||||
void disk_del(disk_t *disk) __attribute__((__stdcall__));
|
||||
|
||||
void hash_oneshot(void *ctx, void *data, size_t len);
|
||||
|
||||
void xfs_user_functions(void);
|
||||
void ext_user_functions(void);
|
||||
void fat_user_functions(void);
|
||||
void ntfs_user_functions(void);
|
||||
|
||||
static inline void kos_enable_acpi() {
|
||||
__asm__ __inline__ __volatile__ (
|
||||
"pushad;"
|
||||
"call enable_acpi;"
|
||||
"popad"
|
||||
:
|
||||
:
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint32_t value;
|
||||
uint32_t errorcode;
|
||||
} f75ret_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t eax;
|
||||
uint32_t ebx;
|
||||
} f76ret_t;
|
||||
|
||||
static inline void kos_stack_init() {
|
||||
__asm__ __inline__ __volatile__ (
|
||||
"pushad;"
|
||||
"call stack_init;"
|
||||
"popad"
|
||||
:
|
||||
:
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
static inline int32_t kos_net_add_device(net_device_t *dev) {
|
||||
int32_t dev_num;
|
||||
__asm__ __inline__ __volatile__ (
|
||||
"call net_add_device"
|
||||
: "=a"(dev_num)
|
||||
: "b"(dev)
|
||||
: "ecx", "edx", "esi", "edi", "memory", "cc");
|
||||
|
||||
return dev_num;
|
||||
}
|
||||
|
||||
void coverage_begin(void);
|
||||
void coverage_end(void);
|
||||
|
||||
extern uint32_t *kos_lfb_base;
|
||||
extern uint16_t *kos_win_stack;
|
||||
extern uint16_t *kos_win_pos;
|
||||
extern uint32_t kos_acpi_ssdt_cnt;
|
||||
extern uint8_t **kos_acpi_ssdt_base;
|
||||
extern size_t *kos_acpi_ssdt_size;
|
||||
extern disk_t disk_list;
|
||||
|
||||
#endif
|
6
makefile
6
makefile
@ -47,7 +47,7 @@ tags: umka.sym
|
||||
trace.o: trace.c trace.h trace_lbr.h
|
||||
$(CC) $(CFLAGS_32) -c $<
|
||||
|
||||
trace_lbr.o: trace_lbr.c trace_lbr.h kolibri.h
|
||||
trace_lbr.o: trace_lbr.c trace_lbr.h umka.h
|
||||
$(CC) $(CFLAGS_32) -c $<
|
||||
|
||||
vdisk.o: vdisk.c
|
||||
@ -56,10 +56,10 @@ vdisk.o: vdisk.c
|
||||
vnet.o: vnet.c
|
||||
$(CC) $(CFLAGS_32) -c $<
|
||||
|
||||
umka_shell.o: umka_shell.c kolibri.h trace.h syscalls.h
|
||||
umka_shell.o: umka_shell.c umka.h trace.h
|
||||
$(CC) $(CFLAGS_32) -c $<
|
||||
|
||||
umka_fuse.o: umka_fuse.c kolibri.h
|
||||
umka_fuse.o: umka_fuse.c umka.h
|
||||
$(CC) $(CFLAGS_32) `pkg-config fuse3 --cflags` -c $<
|
||||
|
||||
tools/mkdirrange: tools/mkdirrange.c
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include "kolibri.h"
|
||||
#include "umka.h"
|
||||
|
||||
#define MSR_IA32_DEBUGCTLMSR 0x1d9
|
||||
#define MSR_IA32_LASTBRANCHFROMIP 0x1db
|
||||
|
@ -1,8 +1,379 @@
|
||||
#ifndef SYSCALLS_H_INCLUDED
|
||||
#define SYSCALLS_H_INCLUDED
|
||||
#ifndef UMKA_H_INCLUDED
|
||||
#define UMKA_H_INCLUDED
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "kolibri.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define BDFE_LEN_CP866 304
|
||||
#define BDFE_LEN_UNICODE 560
|
||||
|
||||
typedef struct {
|
||||
uint32_t left, top, right, bottom;
|
||||
} rect_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t left, top, width, height;
|
||||
} box_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t cpu_usage;
|
||||
uint16_t window_stack_position;
|
||||
uint16_t window_stack_value;
|
||||
uint16_t pad;
|
||||
char process_name[12];
|
||||
uint32_t memory_start;
|
||||
uint32_t used_memory;
|
||||
uint32_t pid;
|
||||
box_t box;
|
||||
uint16_t slot_state;
|
||||
uint16_t pad2;
|
||||
box_t client_box;
|
||||
uint8_t wnd_state;
|
||||
uint8_t pad3[1024-71];
|
||||
} __attribute__((packed)) process_information_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t frame, grab, work_3d_dark, work_3d_light, grab_text, work,
|
||||
work_button, work_button_text, work_text, work_graph;
|
||||
} system_colors_t;
|
||||
|
||||
typedef enum {
|
||||
DEFAULT_ENCODING,
|
||||
CP866,
|
||||
UTF16,
|
||||
UTF8,
|
||||
INVALID_ENCODING,
|
||||
} fs_enc_t;
|
||||
|
||||
typedef enum {
|
||||
F70 = 70,
|
||||
F80 = 80,
|
||||
} f70or80_t;
|
||||
|
||||
enum {
|
||||
ERROR_SUCCESS,
|
||||
ERROR_DISK_BASE,
|
||||
ERROR_UNSUPPORTED_FS,
|
||||
ERROR_UNKNOWN_FS,
|
||||
ERROR_PARTITION,
|
||||
ERROR_FILE_NOT_FOUND,
|
||||
ERROR_END_OF_FILE,
|
||||
ERROR_MEMORY_POINTER,
|
||||
ERROR_DISK_FULL,
|
||||
ERROR_FS_FAIL,
|
||||
ERROR_ACCESS_DENIED,
|
||||
ERROR_DEVICE,
|
||||
ERROR_OUT_OF_MEMORY,
|
||||
};
|
||||
|
||||
typedef struct lhead lhead_t;
|
||||
|
||||
struct lhead {
|
||||
lhead_t *next;
|
||||
lhead_t *prev;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
lhead_t wait_list;
|
||||
uint32_t count;
|
||||
} mutex_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t flags;
|
||||
uint32_t sector_size;
|
||||
uint64_t capacity; // in sectors
|
||||
} diskmediainfo_t;
|
||||
|
||||
typedef struct {
|
||||
uintptr_t pointer;
|
||||
uint32_t data_size;
|
||||
uintptr_t data;
|
||||
uint32_t sad_size;
|
||||
uint32_t search_start;
|
||||
uint32_t sector_size_log;
|
||||
} disk_cache_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t first_sector;
|
||||
uint64_t length; // in sectors
|
||||
void *disk;
|
||||
void *fs_user_functions;
|
||||
} partition_t;
|
||||
|
||||
typedef struct disk_t disk_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t strucsize;
|
||||
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) __attribute__((__stdcall__));
|
||||
} diskfunc_t;
|
||||
|
||||
struct disk_t {
|
||||
disk_t *next;
|
||||
disk_t *prev;
|
||||
diskfunc_t *functions;
|
||||
const char *name;
|
||||
void *userdata;
|
||||
uint32_t driver_flags;
|
||||
uint32_t ref_count;
|
||||
mutex_t media_lock;
|
||||
uint8_t media_inserted;
|
||||
uint8_t media_used;
|
||||
uint16_t padding;
|
||||
uint32_t media_ref_count;
|
||||
diskmediainfo_t media_info;
|
||||
uint32_t num_partitions;
|
||||
partition_t **partitions;
|
||||
uint32_t cache_size;
|
||||
mutex_t cache_lock;
|
||||
disk_cache_t sys_cache;
|
||||
disk_cache_t app_cache;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t attr;
|
||||
uint32_t enc;
|
||||
uint32_t ctime;
|
||||
uint32_t cdate;
|
||||
uint32_t atime;
|
||||
uint32_t adate;
|
||||
uint32_t mtime;
|
||||
uint32_t mdate;
|
||||
uint64_t size;
|
||||
char name[0];
|
||||
} bdfe_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t status;
|
||||
uint32_t count;
|
||||
} f7080ret_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t sf;
|
||||
uint64_t offset;
|
||||
uint32_t count;
|
||||
void *buf;
|
||||
union {
|
||||
struct {
|
||||
uint8_t zero;
|
||||
const char *path;
|
||||
} __attribute__((packed)) f70;
|
||||
struct {
|
||||
uint32_t path_encoding;
|
||||
const char *path;
|
||||
} f80;
|
||||
} u;
|
||||
} __attribute__((packed)) f7080s0arg_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t sf;
|
||||
uint32_t offset;
|
||||
uint32_t encoding;
|
||||
uint32_t size;
|
||||
void *buf;
|
||||
union {
|
||||
struct {
|
||||
uint8_t zero;
|
||||
const char *path;
|
||||
} __attribute__((packed)) f70;
|
||||
struct {
|
||||
uint32_t path_encoding;
|
||||
const char *path;
|
||||
} f80;
|
||||
} u;
|
||||
} __attribute__((packed)) f7080s1arg_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t version;
|
||||
uint32_t cnt;
|
||||
uint32_t total_cnt;
|
||||
uint32_t zeroed[5];
|
||||
bdfe_t bdfes[0];
|
||||
} f7080s1info_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t sf;
|
||||
uint32_t reserved1;
|
||||
uint32_t flags;
|
||||
uint32_t reserved2;
|
||||
void *buf;
|
||||
union {
|
||||
struct {
|
||||
uint8_t zero;
|
||||
const char *path;
|
||||
} __attribute__((packed)) f70;
|
||||
struct {
|
||||
uint32_t path_encoding;
|
||||
const char *path;
|
||||
} f80;
|
||||
} u;
|
||||
} __attribute__((packed)) f7080s5arg_t;
|
||||
|
||||
#define KF_READONLY 0x01
|
||||
#define KF_HIDDEN 0x02
|
||||
#define KF_SYSTEM 0x04
|
||||
#define KF_LABEL 0x08
|
||||
#define KF_FOLDER 0x10
|
||||
#define KF_ATTR_CNT 5
|
||||
|
||||
#define HASH_SIZE 32
|
||||
typedef struct {
|
||||
uint8_t hash[HASH_SIZE];
|
||||
uint8_t opaque[1024-HASH_SIZE];
|
||||
} hash_context;
|
||||
|
||||
typedef struct {
|
||||
uint32_t edi;
|
||||
uint32_t esi;
|
||||
uint32_t ebp;
|
||||
uint32_t esp;
|
||||
uint32_t ebx;
|
||||
uint32_t edx;
|
||||
uint32_t ecx;
|
||||
uint32_t eax;
|
||||
} pushad_t;
|
||||
|
||||
#define NET_TYPE_ETH 1
|
||||
#define NET_TYPE_SLIP 2
|
||||
|
||||
// Link state
|
||||
#define ETH_LINK_DOWN 0x0 // Link is down
|
||||
#define ETH_LINK_UNKNOWN 0x1 // There could be an active link
|
||||
#define ETH_LINK_FD 0x2 // full duplex flag
|
||||
#define ETH_LINK_10M 0x4 // 10 mbit
|
||||
#define ETH_LINK_100M 0x8 // 100 mbit
|
||||
#define ETH_LINK_1G 0xc // gigabit
|
||||
|
||||
// Ethernet protocol numbers
|
||||
#define ETHER_PROTO_ARP 0x0608
|
||||
#define ETHER_PROTO_IPv4 0x0008
|
||||
#define ETHER_PROTO_IPv6 0xDD86
|
||||
#define ETHER_PROTO_PPP_DISCOVERY 0x6388
|
||||
#define ETHER_PROTO_PPP_SESSION 0x6488
|
||||
|
||||
// Internet protocol numbers
|
||||
#define IP_PROTO_IP 0
|
||||
#define IP_PROTO_ICMP 1
|
||||
#define IP_PROTO_TCP 6
|
||||
#define IP_PROTO_UDP 17
|
||||
#define IP_PROTO_RAW 255
|
||||
|
||||
// IP options
|
||||
#define IP_TOS 1
|
||||
#define IP_TTL 2
|
||||
#define IP_HDRINCL 3
|
||||
|
||||
// PPP protocol numbers
|
||||
#define PPP_PROTO_IPv4 0x2100
|
||||
#define PPP_PROTO_IPV6 0x5780
|
||||
#define PPP_PROTO_ETHERNET 666
|
||||
|
||||
// Protocol family
|
||||
#define AF_INET4 AF_INET
|
||||
|
||||
typedef struct {
|
||||
uint32_t device_type; // type field
|
||||
uint32_t mtu; // Maximal Transmission Unit
|
||||
char *name; // ptr to 0 terminated string
|
||||
|
||||
void *unload; // ptrs to driver functions
|
||||
void *reset;
|
||||
void *transmit;
|
||||
|
||||
uint64_t bytes_tx; // statistics, updated by the driver
|
||||
uint64_t bytes_rx;
|
||||
uint32_t packets_tx;
|
||||
uint32_t packets_rx;
|
||||
|
||||
uint32_t link_state; // link state (0 = no link)
|
||||
uint32_t hwacc; // bitmask stating enabled HW accelerations (offload
|
||||
// engines)
|
||||
uint8_t mac[6];
|
||||
} net_device_t; // NET_DEVICE
|
||||
|
||||
typedef struct {
|
||||
void *next; // pointer to next frame in list
|
||||
void *prev; // pointer to previous frame in list
|
||||
net_device_t *device; // ptr to NET_DEVICE structure
|
||||
uint32_t type; // encapsulation type: e.g. Ethernet
|
||||
size_t length; // size of encapsulated data
|
||||
size_t offset; // offset to actual data (24 bytes for default frame)
|
||||
uint8_t data[0];
|
||||
} net_buff_t;
|
||||
|
||||
void kos_init(void);
|
||||
void i40(void);
|
||||
uint32_t kos_time_to_epoch(uint32_t *time);
|
||||
|
||||
void *disk_add(diskfunc_t *disk, const char *name, void *userdata, uint32_t flags) __attribute__((__stdcall__));
|
||||
void *disk_media_changed(diskfunc_t *disk, int inserted) __attribute__((__stdcall__));
|
||||
void disk_del(disk_t *disk) __attribute__((__stdcall__));
|
||||
|
||||
void hash_oneshot(void *ctx, void *data, size_t len);
|
||||
|
||||
void xfs_user_functions(void);
|
||||
void ext_user_functions(void);
|
||||
void fat_user_functions(void);
|
||||
void ntfs_user_functions(void);
|
||||
|
||||
static inline void kos_enable_acpi() {
|
||||
__asm__ __inline__ __volatile__ (
|
||||
"pushad;"
|
||||
"call enable_acpi;"
|
||||
"popad"
|
||||
:
|
||||
:
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint32_t value;
|
||||
uint32_t errorcode;
|
||||
} f75ret_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t eax;
|
||||
uint32_t ebx;
|
||||
} f76ret_t;
|
||||
|
||||
static inline void kos_stack_init() {
|
||||
__asm__ __inline__ __volatile__ (
|
||||
"pushad;"
|
||||
"call stack_init;"
|
||||
"popad"
|
||||
:
|
||||
:
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
static inline int32_t kos_net_add_device(net_device_t *dev) {
|
||||
int32_t dev_num;
|
||||
__asm__ __inline__ __volatile__ (
|
||||
"call net_add_device"
|
||||
: "=a"(dev_num)
|
||||
: "b"(dev)
|
||||
: "ecx", "edx", "esi", "edi", "memory", "cc");
|
||||
|
||||
return dev_num;
|
||||
}
|
||||
|
||||
void coverage_begin(void);
|
||||
void coverage_end(void);
|
||||
|
||||
extern uint32_t *kos_lfb_base;
|
||||
extern uint16_t *kos_win_stack;
|
||||
extern uint16_t *kos_win_pos;
|
||||
extern uint32_t kos_acpi_ssdt_cnt;
|
||||
extern uint8_t **kos_acpi_ssdt_base;
|
||||
extern size_t *kos_acpi_ssdt_size;
|
||||
extern disk_t disk_list;
|
||||
|
||||
static inline void umka_i40(pushad_t *regs) {
|
||||
|
||||
@ -692,4 +1063,4 @@ static inline f76ret_t umka_sys_net_ipv4_set_addr(uint32_t dev_num,
|
||||
// Function 76, Protocol 5 - ARP, Subfunction 6, Send ARP announce ==
|
||||
// Function 76, Protocol 5 - ARP, Subfunction 7, Read # conflicts ===
|
||||
|
||||
#endif
|
||||
#endif // UMKA_H_INCLUDED
|
@ -32,8 +32,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "vdisk.h"
|
||||
#include "kolibri.h"
|
||||
#include "syscalls.h"
|
||||
#include "umka.h"
|
||||
|
||||
#define DIRENTS_TO_READ 100
|
||||
|
||||
|
@ -35,8 +35,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#include "vdisk.h"
|
||||
#include "vnet.h"
|
||||
#include "kolibri.h"
|
||||
#include "syscalls.h"
|
||||
#include "umka.h"
|
||||
#include "trace.h"
|
||||
#include "lodepng.h"
|
||||
|
||||
|
2
vdisk.c
2
vdisk.c
@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <errno.h>
|
||||
#include "kolibri.h"
|
||||
#include "umka.h"
|
||||
#include "trace.h"
|
||||
#include "vdisk.h"
|
||||
|
||||
|
2
vdisk.h
2
vdisk.h
@ -3,7 +3,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "kolibri.h"
|
||||
#include "umka.h"
|
||||
|
||||
void *vdisk_init(const char *fname, int adjust_cache_size, size_t cache_size);
|
||||
|
||||
|
2
vnet.c
2
vnet.c
@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <errno.h>
|
||||
#include "kolibri.h"
|
||||
#include "umka.h"
|
||||
#include "trace.h"
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
Reference in New Issue
Block a user