103 lines
4.2 KiB
C
103 lines
4.2 KiB
C
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdatomic.h>
|
|
#include <exec/list.h>
|
|
#include <exec/port.h>
|
|
#include <exec/mem.h>
|
|
#include <exec/library.h>
|
|
#include <exec/device.h>
|
|
#include <exec/irq.h>
|
|
#include <exec/sync.h>
|
|
#include <exec/task.h>
|
|
#include <exec/detect.h>
|
|
#include <exec/hal.h>
|
|
|
|
struct IExec {
|
|
/* list.c */
|
|
void (*NewList)(struct List *list, int protect);
|
|
void (*Enqueue)(struct List *list, struct Node *node);
|
|
void (*Insert)(struct List *list, struct Node *node, struct Node *after);
|
|
void (*Remove)(struct List *list, struct Node *node);
|
|
void (*AddHead)(struct List *list, struct Node *node);
|
|
void (*AddTail)(struct List *list, struct Node *node);
|
|
struct Node *(*RemHead)(struct List *list);
|
|
struct Node *(*RemTail)(struct List *list);
|
|
struct Node *(*FindNode)(struct List *list, char *name);
|
|
void (*SetPriority)(struct Node *node, int8_t priority);
|
|
|
|
/* port.c */
|
|
void (*NewPort)(struct Port *port, uint8_t flags);
|
|
struct Port *(*CreatePort)(char *name, int pri);
|
|
void (*PutMsg)(struct Port *port, struct Message *msg);
|
|
struct Message *(*GetMsg)(struct Port *port);
|
|
struct Message *(*WaitPort)(struct Port *port);
|
|
void (*AssignPort)(struct Port *port);
|
|
void (*AddPort)(struct Port *port);
|
|
void (*ReplyMsg)(struct Message *msg);
|
|
|
|
/* mem.c */
|
|
void *(*AllocMem)(size_t size);
|
|
void *(*AllocMemEx)(size_t size, uint8_t flags);
|
|
void (*FreeMem)(void *block);
|
|
void (*FreeMemEx)(void *block, size_t size);
|
|
|
|
/* library.c */
|
|
struct Library *(*MakeLibrary)(uintptr_t *vectors, void *structure, uintptr_t init, uint32_t dataSize);
|
|
void (*AddLibrary)(struct Library *library);
|
|
|
|
/* device.c */
|
|
void (*AddDevice)(struct Device *device);
|
|
int (*OpenDevice)(char *devName, uint32_t unitNumber, struct IORequest *ior, uint32_t flags);
|
|
uint32_t (*BeginIO)(struct IORequest *ior);
|
|
uint32_t (*WaitIO)(struct IORequest *ior);
|
|
uint32_t (*DoIO)(struct IORequest *ior);
|
|
uint32_t (*SendIO)(struct IORequest *ior);
|
|
struct IORequest *(*CreateExtIO)(struct Port *reply_port, uint32_t size);
|
|
struct IOStdReq *(*CreateStdIO)(struct Port *reply_port);
|
|
void (*CompleteIO)(struct IORequest *ior);
|
|
|
|
/* irq.c */
|
|
void (*AddIntServer)(uint16_t irq, struct Interrupt *interrupt);
|
|
void (*RemIntServer)(uint16_t irq, struct Interrupt *interrupt);
|
|
|
|
/* sync.c */
|
|
void (*NewSemaphore)(struct Semaphore *semaphore, int count, uint8_t type);
|
|
void (*NewMutex)(struct Semaphore *semaphore, uint8_t type);
|
|
void (*Acquire)(struct Semaphore *semaphore);
|
|
void (*Release)(struct Semaphore *semaphore);
|
|
|
|
/* task.c */
|
|
struct Task *(*ThisTask)(void);
|
|
void (*AddTask)(struct Task *task, uintptr_t initial_pc, uintptr_t final_pc);
|
|
struct Task *(*CreateTask)(char *name, int8_t pri, uintptr_t initial_pc, size_t stack_size);
|
|
void (*Yield)(void);
|
|
void (*Block)(struct Task *task, atomic_int *address, int value);
|
|
void (*Delay)(int ticks);
|
|
int (*Forbid)(void);
|
|
int (*Permit)(void);
|
|
uint8_t (*AllocSignal)(uint8_t hint);
|
|
void (*FreeSignal)(uint8_t signal);
|
|
void (*Signal)(struct Task *task, Signals signals);
|
|
Signals (*Wait)(Signals signals);
|
|
|
|
/* detect.c */
|
|
struct Detect *(*CreateDetect)(char* compat, uint8_t reg_count, uint8_t irq_count);
|
|
void (*SetDetectRegion)(struct Detect* entry, uint8_t index, enum HalAddressSpace space, uintptr_t base, size_t limit);
|
|
void (*SetDetectIRQ)(struct Detect* entry, uint8_t index, uint8_t irq);
|
|
void (*AddDetect)(struct Detect* entry);
|
|
int (*BuildCompat)(char *str, ...);
|
|
|
|
/* hal.c */
|
|
void (*HalWriteIO8)(enum HalAddressSpace space, uintptr_t port, uint8_t value);
|
|
void (*HalWriteIO16)(enum HalAddressSpace space, uintptr_t port, uint16_t value);
|
|
void (*HalWriteIO32)(enum HalAddressSpace space, uintptr_t port, uint32_t value);
|
|
uint8_t (*HalReadIO8)(enum HalAddressSpace space, uintptr_t port);
|
|
uint16_t (*HalReadIO16)(enum HalAddressSpace space, uintptr_t port);
|
|
uint32_t (*HalReadIO32)(enum HalAddressSpace space, uintptr_t port);
|
|
void (*HalMaskInterrupt)(int irq);
|
|
void (*HalUnmaskInterrupt)(int irq);
|
|
};
|
|
|
|
extern const struct IExec exec_api; |