aboutsummaryrefslogtreecommitdiff
path: root/pk/file.h
diff options
context:
space:
mode:
Diffstat (limited to 'pk/file.h')
-rw-r--r--pk/file.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/pk/file.h b/pk/file.h
index c9f7ce4..8a7cb41 100644
--- a/pk/file.h
+++ b/pk/file.h
@@ -8,12 +8,34 @@
#include <stdint.h>
#include "atomic.h"
+enum file_type
+{
+ FILE_HOST,
+ FILE_DEVICE
+};
+
typedef struct file
{
- int kfd; // file descriptor on the host side of the HTIF
+ enum file_type typ;
uint32_t refcnt;
+ uint64_t padding[1]; // padding to make room for device parameters
} file_t;
+typedef struct host_file
+{
+ enum file_type typ;
+ uint32_t refcnt;
+ int32_t kfd; // file descriptor on the host side of the HTIF
+} host_file_t;
+
+typedef struct device
+{
+ enum file_type typ;
+ uint32_t refcnt;
+ uint64_t base;
+ uint64_t size;
+} device_t;
+
extern file_t files[];
#define stdin (files + 0)
#define stdout (files + 1)
@@ -37,4 +59,8 @@ int fd_close(int fd);
void file_init();
+device_t *device_open(const char *name, int flags);
+ssize_t device_pread(device_t *dev, void *buf, size_t size, off_t offset);
+ssize_t device_pwrite(device_t *dev, void *buf, size_t size, off_t offset);
+
#endif