2023-10-24 23:39:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* system.h
|
|
|
|
|
* Системные вызовы
|
|
|
|
|
*
|
|
|
|
|
* Заголовочный файл содержащий заготовку для работы с системными вызовами
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef SYSTEM_H
|
|
|
|
|
#define SYSTEM_H
|
|
|
|
|
|
2023-11-26 13:12:57 +03:00
|
|
|
|
#include <modstd.h>
|
2024-01-20 21:44:02 +03:00
|
|
|
|
#include <types.h>
|
2023-11-26 13:12:57 +03:00
|
|
|
|
|
2024-01-20 21:44:02 +03:00
|
|
|
|
extern void *(*alloc)(uint64_t size);
|
|
|
|
|
extern void (*free)(void *ptr);
|
|
|
|
|
extern void (*fb_printf)(char *str, ...);
|
|
|
|
|
extern module_info_t *(*get_module)(char *module_id);
|
2024-01-21 19:25:04 +03:00
|
|
|
|
extern module_info_t *(*mod_list_get)(uint64_t *count);
|
2024-01-20 21:44:02 +03:00
|
|
|
|
extern framebuffer_t (*alloc_framebuffer)( );
|
|
|
|
|
extern void (*free_framebuffer)(framebuffer_t *frame);
|
|
|
|
|
extern void (*exit)(int code);
|
|
|
|
|
extern int (*get_error)( );
|
|
|
|
|
extern sys_info_t *(*get_info)( );
|
|
|
|
|
extern uint64_t (*new_thread)(uint64_t func);
|
|
|
|
|
extern int (*delete_thread)(uint64_t thread_id);
|
|
|
|
|
extern time_t (*get_time)( );
|
|
|
|
|
extern uint64_t offset;
|
|
|
|
|
|
|
|
|
|
void init_env(env_t *loader_env);
|
|
|
|
|
void *realloc(void *addr, size_t size);
|
2023-11-26 18:23:58 +03:00
|
|
|
|
|
2023-12-15 17:59:43 +03:00
|
|
|
|
static inline void outb(uint16_t port, uint8_t val) {
|
|
|
|
|
asm volatile("outb %0, %1" : : "a"(val), "Nd"(port));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint8_t inb(uint16_t port) {
|
|
|
|
|
uint8_t ret;
|
|
|
|
|
asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port));
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void outw(uint16_t port, uint16_t val) {
|
|
|
|
|
asm volatile("outw %0, %1" : : "a"(val), "Nd"(port));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint16_t inw(uint16_t port) {
|
|
|
|
|
uint16_t ret;
|
|
|
|
|
asm volatile("inw %1, %0" : "=a"(ret) : "Nd"(port));
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint32_t inl(uint16_t port) {
|
|
|
|
|
uint32_t data;
|
|
|
|
|
asm volatile("inl %1, %0" : "=a"(data) : "Nd"(port));
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void outl(uint16_t port, uint32_t data) {
|
|
|
|
|
asm volatile("outl %0, %1" : : "a"(data), "Nd"(port));
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-24 23:39:00 +03:00
|
|
|
|
#endif // system.h
|