kernel: remove redundant header files
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
#ifndef MANGO_BLOCK_H_
|
||||
#define MANGO_BLOCK_H_
|
||||
|
||||
#include <mango/types.h>
|
||||
#include <mango/btree.h>
|
||||
#include <mango/locks.h>
|
||||
#include <mango/status.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
enum block_device_flags {
|
||||
BLOCK_DEVICE_NO_BCACHE = 0x01u,
|
||||
};
|
||||
|
||||
struct bcache {
|
||||
unsigned int b_sector_size;
|
||||
unsigned int b_sectors_per_page;
|
||||
struct btree b_pagetree;
|
||||
};
|
||||
|
||||
struct bcache_sector {
|
||||
struct vm_page *sect_page;
|
||||
unsigned int sect_index;
|
||||
void *sect_buf;
|
||||
bool sect_present;
|
||||
};
|
||||
|
||||
extern struct bcache *bcache_create(unsigned int block_size);
|
||||
extern void bcache_destroy(struct bcache *cache);
|
||||
|
||||
extern kern_status_t bcache_init(struct bcache *cache, unsigned int block_size);
|
||||
extern void bcache_deinit(struct bcache *cache);
|
||||
|
||||
extern kern_status_t bcache_get(struct bcache *cache, sectors_t at, bool create, struct bcache_sector *out);
|
||||
extern void bcache_mark_present(struct bcache_sector *sect);
|
||||
|
||||
#endif
|
||||
@@ -1,336 +0,0 @@
|
||||
#ifndef MANGO_DEVICE_H_
|
||||
#define MANGO_DEVICE_H_
|
||||
|
||||
#include <mango/queue.h>
|
||||
#include <mango/btree.h>
|
||||
#include <mango/status.h>
|
||||
#include <mango/bitmap.h>
|
||||
#include <mango/object.h>
|
||||
#include <mango/block.h>
|
||||
#include <mango/fb.h>
|
||||
#include <mango/ringbuffer.h>
|
||||
|
||||
struct device;
|
||||
struct input_event;
|
||||
struct input_event_hook;
|
||||
struct tty_device;
|
||||
|
||||
#define DEV_NAME_MAX OBJECT_NAME_MAX
|
||||
#define DEV_MODEL_NAME_MAX 64
|
||||
#define DEV_MAJOR_MAX 1024
|
||||
#define DEV_MINOR_MAX 1024
|
||||
#define DEV_MAJOR_INVALID ((unsigned int)0)
|
||||
#define DEV_MINOR_INVALID ((unsigned int)0)
|
||||
|
||||
#define INPUT_DEVICE_EVENT_QUEUE_SIZE 128
|
||||
#define INPUT_DEVICE_MAX 4096
|
||||
#define BLOCK_DEVICE_MAX 4096
|
||||
#define FRAMEBUFFER_DEVICE_MAX 4096
|
||||
|
||||
#define BLOCK_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_BLOCK ? &(dev)->blk : NULL)
|
||||
#define CHAR_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_CHAR ? &(dev)->chr : NULL)
|
||||
#define NET_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_NET ? &(dev)->net : NULL)
|
||||
#define INPUT_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_INPUT ? &(dev)->input : NULL)
|
||||
#define BUS_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_BUS ? &(dev)->bus : NULL)
|
||||
#define FRAMEBUFFER_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_FRAMEBUFFER ? &(dev)->fb : NULL)
|
||||
|
||||
enum device_type {
|
||||
DEV_TYPE_UNKNOWN = 0,
|
||||
DEV_TYPE_BLOCK,
|
||||
DEV_TYPE_CHAR,
|
||||
DEV_TYPE_NET,
|
||||
DEV_TYPE_INPUT,
|
||||
DEV_TYPE_BUS,
|
||||
DEV_TYPE_FRAMEBUFFER,
|
||||
};
|
||||
|
||||
struct iovec {
|
||||
void *io_buf;
|
||||
size_t io_len;
|
||||
};
|
||||
|
||||
struct device_type_ops {
|
||||
kern_status_t(*read)(struct device *, void *, size_t, size_t, size_t *, mango_flags_t);
|
||||
kern_status_t(*write)(struct device *, const void *, size_t, size_t, size_t *, mango_flags_t);
|
||||
kern_status_t(*register_device)(struct device *);
|
||||
};
|
||||
|
||||
struct block_device_ops {
|
||||
kern_status_t(*read_blocks)(struct device *, sectors_t, size_t *, struct iovec *, size_t, mango_flags_t);
|
||||
kern_status_t(*write_blocks)(struct device *, sectors_t, size_t *, struct iovec *, size_t, mango_flags_t);
|
||||
kern_status_t(*ioctl)(struct device *, unsigned int, void *);
|
||||
};
|
||||
|
||||
struct net_device_ops {
|
||||
kern_status_t(*online)(struct device *);
|
||||
kern_status_t(*offline)(struct device *);
|
||||
kern_status_t(*transmit)(struct device *, const void *, size_t);
|
||||
kern_status_t(*ioctl)(struct device *, unsigned int, void *);
|
||||
};
|
||||
|
||||
struct char_device_ops {
|
||||
kern_status_t(*read)(struct device *, void *, size_t, size_t, size_t *, mango_flags_t);
|
||||
kern_status_t(*write)(struct device *, const void *, size_t, size_t, size_t *, mango_flags_t);
|
||||
};
|
||||
|
||||
struct input_device_ops {
|
||||
kern_status_t(*ioctl)(struct device *, unsigned int, void *);
|
||||
};
|
||||
|
||||
struct bus_device_ops {
|
||||
kern_status_t(*scan)(struct device *);
|
||||
};
|
||||
|
||||
struct framebuffer_device_ops {
|
||||
kern_status_t(*set_varinfo)(struct device *, const struct framebuffer_varinfo *);
|
||||
};
|
||||
|
||||
struct block_device {
|
||||
struct block_device_ops *b_ops;
|
||||
struct bcache b_cache;
|
||||
enum block_device_flags b_flags;
|
||||
unsigned int b_id;
|
||||
unsigned int b_sector_size;
|
||||
sectors_t b_capacity;
|
||||
};
|
||||
|
||||
struct char_device {
|
||||
struct char_device_ops *c_ops;
|
||||
/* only valid for TTY devices */
|
||||
struct tty_device *c_tty;
|
||||
};
|
||||
|
||||
struct net_device {
|
||||
struct net_device_ops *n_ops;
|
||||
};
|
||||
|
||||
struct input_device {
|
||||
struct input_device_ops *i_ops;
|
||||
unsigned int i_id;
|
||||
struct ringbuffer i_events;
|
||||
struct queue i_hooks;
|
||||
};
|
||||
|
||||
struct bus_device {
|
||||
struct queue_entry b_buslist;
|
||||
struct bus_device_ops *b_ops;
|
||||
};
|
||||
|
||||
struct framebuffer_device {
|
||||
unsigned int fb_id;
|
||||
struct framebuffer_device_ops *fb_ops;
|
||||
struct framebuffer_varinfo fb_varinfo;
|
||||
struct framebuffer_fixedinfo fb_fixedinfo;
|
||||
};
|
||||
|
||||
struct device {
|
||||
struct object dev_base;
|
||||
unsigned int dev_minor;
|
||||
|
||||
enum device_type dev_type;
|
||||
struct device *dev_parent;
|
||||
struct driver *dev_owner;
|
||||
struct queue dev_children;
|
||||
struct queue_entry dev_childent;
|
||||
struct btree_node dev_driverent;
|
||||
char dev_name[DEV_NAME_MAX];
|
||||
char dev_model_name[DEV_MODEL_NAME_MAX];
|
||||
|
||||
void *dev_bus_priv;
|
||||
void *dev_priv;
|
||||
|
||||
union {
|
||||
struct block_device blk;
|
||||
struct char_device chr;
|
||||
struct net_device net;
|
||||
struct input_device input;
|
||||
struct bus_device bus;
|
||||
struct framebuffer_device fb;
|
||||
};
|
||||
};
|
||||
|
||||
struct driver;
|
||||
|
||||
struct driver_ops {
|
||||
/* called when a bus driver finds a device for this driver to manage. */
|
||||
kern_status_t(*bind)(struct driver *, struct device *, struct device *);
|
||||
/* called when driver is registered. */
|
||||
kern_status_t(*install)(struct driver *);
|
||||
/* called when driver is unregistered. */
|
||||
kern_status_t(*uninstall)(struct driver *);
|
||||
};
|
||||
|
||||
struct driver {
|
||||
struct kext *drv_owner;
|
||||
unsigned int drv_major;
|
||||
DECLARE_BITMAP(drv_minors, DEV_MINOR_MAX);
|
||||
char drv_name[DEV_NAME_MAX];
|
||||
struct btree drv_children;
|
||||
struct btree_node drv_ent;
|
||||
spin_lock_t drv_lock;
|
||||
|
||||
void *drv_priv;
|
||||
struct driver_ops *drv_ops;
|
||||
};
|
||||
|
||||
extern kern_status_t device_init(void);
|
||||
extern struct device *root_device(void);
|
||||
extern struct device *misc_device(void);
|
||||
|
||||
extern struct device *device_alloc(void);
|
||||
static inline void device_lock(struct device *dev)
|
||||
{
|
||||
object_lock(&dev->dev_base);
|
||||
}
|
||||
|
||||
static inline void device_unlock(struct device *dev)
|
||||
{
|
||||
object_unlock(&dev->dev_base);
|
||||
}
|
||||
|
||||
static inline void device_lock_irqsave(struct device *dev, unsigned long *flags)
|
||||
{
|
||||
object_lock_irqsave(&dev->dev_base, flags);
|
||||
}
|
||||
|
||||
static inline void device_unlock_irqrestore(struct device *dev, unsigned long flags)
|
||||
{
|
||||
object_unlock_irqrestore(&dev->dev_base, flags);
|
||||
}
|
||||
|
||||
extern kern_status_t device_read(struct device *dev, void *buf, size_t offset, size_t size, size_t *bytes_read, mango_flags_t flags);
|
||||
extern kern_status_t device_write(struct device *dev, const void *buf, size_t offset, size_t size, size_t *bytes_written, mango_flags_t flags);
|
||||
|
||||
extern struct device *cast_to_device(struct object *obj);
|
||||
|
||||
extern struct device *generic_device_create(void);
|
||||
extern struct char_device *char_device_create(void);
|
||||
extern struct block_device *block_device_create(void);
|
||||
extern struct net_device *net_device_create(void);
|
||||
extern struct input_device *input_device_create(void);
|
||||
extern struct bus_device *bus_device_create(void);
|
||||
extern struct framebuffer_device *framebuffer_device_create(void);
|
||||
|
||||
extern struct char_device *char_device_from_generic(struct device *dev);
|
||||
extern struct block_device *block_device_from_generic(struct device *dev);
|
||||
extern struct net_device *net_device_from_generic(struct device *dev);
|
||||
extern struct input_device *input_device_from_generic(struct device *dev);
|
||||
extern struct bus_device *bus_device_from_generic(struct device *dev);
|
||||
extern struct framebuffer_device *framebuffer_device_from_generic(struct device *dev);
|
||||
|
||||
static inline struct device *char_device_base(struct char_device *dev)
|
||||
{
|
||||
return (struct device *)((char *)dev - offsetof(struct device, chr));
|
||||
}
|
||||
|
||||
static inline struct device *block_device_base(struct block_device *dev)
|
||||
{
|
||||
return (struct device *)((char *)dev - offsetof(struct device, blk));
|
||||
}
|
||||
|
||||
static inline struct device *net_device_base(struct net_device *dev)
|
||||
{
|
||||
return (struct device *)((char *)dev - offsetof(struct device, net));
|
||||
}
|
||||
|
||||
static inline struct device *input_device_base(struct input_device *dev)
|
||||
{
|
||||
return (struct device *)((char *)dev - offsetof(struct device, input));
|
||||
}
|
||||
|
||||
static inline struct device *bus_device_base(struct bus_device *dev)
|
||||
{
|
||||
return (struct device *)((char *)dev - offsetof(struct device, bus));
|
||||
}
|
||||
|
||||
static inline struct device *framebuffer_device_base(struct framebuffer_device *dev)
|
||||
{
|
||||
return (struct device *)((char *)dev - offsetof(struct device, fb));
|
||||
}
|
||||
|
||||
static inline struct object *char_device_object(struct char_device *dev)
|
||||
{
|
||||
return &char_device_base(dev)->dev_base;
|
||||
}
|
||||
|
||||
static inline struct object *block_device_object(struct block_device *dev)
|
||||
{
|
||||
return &block_device_base(dev)->dev_base;
|
||||
}
|
||||
|
||||
static inline struct object *net_device_object(struct net_device *dev)
|
||||
{
|
||||
return &net_device_base(dev)->dev_base;
|
||||
}
|
||||
|
||||
static inline struct object *input_device_object(struct input_device *dev)
|
||||
{
|
||||
return &input_device_base(dev)->dev_base;
|
||||
}
|
||||
|
||||
static inline struct object *bus_device_object(struct bus_device *dev)
|
||||
{
|
||||
return &bus_device_base(dev)->dev_base;
|
||||
}
|
||||
|
||||
static inline struct object *framebuffer_device_object(struct framebuffer_device *dev)
|
||||
{
|
||||
return &framebuffer_device_base(dev)->dev_base;
|
||||
}
|
||||
|
||||
extern kern_status_t device_register(struct device *dev, struct driver *owner, struct device *parent);
|
||||
static inline struct device *device_ref(struct device *dev)
|
||||
{
|
||||
return cast_to_device(object_ref(&dev->dev_base));
|
||||
}
|
||||
static inline void device_deref(struct device *dev)
|
||||
{
|
||||
object_deref(&dev->dev_base);
|
||||
}
|
||||
|
||||
extern kern_status_t input_device_report_event(struct input_device *dev, const struct input_event *ev, bool noblock);
|
||||
extern kern_status_t input_device_read(struct device *dev, void *buf, size_t offset,
|
||||
size_t size, size_t *bytes_read, mango_flags_t flags);
|
||||
extern kern_status_t input_device_add_hook(struct device *dev, struct input_event_hook *hook);
|
||||
extern kern_status_t input_device_remove_hook(struct device *dev, struct input_event_hook *hook);
|
||||
|
||||
extern struct driver *driver_create(struct kext *self, const char *name);
|
||||
extern kern_status_t driver_destroy(struct driver *driver);
|
||||
extern kern_status_t driver_init(struct driver *driver, struct kext *self, const char *name);
|
||||
extern kern_status_t driver_deinit(struct driver *driver);
|
||||
extern kern_status_t driver_register(struct driver *driver);
|
||||
extern kern_status_t driver_unregister(struct driver *driver);
|
||||
extern unsigned int driver_alloc_minor(struct driver *driver);
|
||||
extern void driver_free_minor(struct driver *driver, unsigned int minor);
|
||||
extern struct device *driver_get_device(struct driver *driver, unsigned int minor);
|
||||
extern kern_status_t driver_add_device(struct driver *driver, struct device *dev);
|
||||
extern kern_status_t driver_remove_device(struct driver *driver, struct device *dev);
|
||||
extern struct driver *system_driver(void);
|
||||
|
||||
extern kern_status_t framebuffer_get_fixedinfo(struct device *dev, struct framebuffer_fixedinfo *out);
|
||||
extern kern_status_t framebuffer_get_varinfo(struct device *dev, struct framebuffer_varinfo *out);
|
||||
extern kern_status_t framebuffer_set_varinfo(struct device *dev, const struct framebuffer_varinfo *varinfo);
|
||||
|
||||
static inline void driver_lock(struct driver *driver)
|
||||
{
|
||||
spin_lock(&driver->drv_lock);
|
||||
}
|
||||
|
||||
static inline void driver_unlock(struct driver *driver)
|
||||
{
|
||||
spin_unlock(&driver->drv_lock);
|
||||
}
|
||||
|
||||
static inline void driver_lock_irqsave(struct driver *driver, unsigned long *flags)
|
||||
{
|
||||
spin_lock_irqsave(&driver->drv_lock, flags);
|
||||
}
|
||||
|
||||
static inline void driver_unlock_irqrestore(struct driver *driver, unsigned long flags)
|
||||
{
|
||||
spin_unlock_irqrestore(&driver->drv_lock, flags);
|
||||
}
|
||||
|
||||
extern kern_status_t scan_all_buses(void);
|
||||
|
||||
#endif
|
||||
@@ -1,99 +0,0 @@
|
||||
#ifndef MANGO_KEXT_H_
|
||||
#define MANGO_KEXT_H_
|
||||
|
||||
#include <mango/status.h>
|
||||
#include <mango/object.h>
|
||||
#include <mango/compiler.h>
|
||||
#include <mango/btree.h>
|
||||
|
||||
#define KERNEL_KEXT_ID "net.doorstuck.mango-kernel"
|
||||
#define KEXT_IDENT_MAX 80
|
||||
#define KEXT_NO_DEPENDENCIES NULL
|
||||
|
||||
#define __KEXT_INFO_VARNAME_2(a, b) a ## b
|
||||
#define __KEXT_INFO_VARNAME_1(a, b) __KEXT_INFO_VARNAME_2(a, b)
|
||||
|
||||
#ifdef MANGO_INTERNAL
|
||||
#define __KEXT_INFO_LINKAGE static
|
||||
#define __KEXT_INFO_VARNAME() __KEXT_INFO_VARNAME_1(__kext_info, __LINE__)
|
||||
#define __KEXT_INFO_DEPNAME() __KEXT_INFO_VARNAME_1(__kext_deps, __LINE__)
|
||||
#define __KEXT_INFO_FLAGS KEXT_INTERNAL
|
||||
#define __KEXT_INFO_ALIGNMENT 0x80
|
||||
#else
|
||||
#define __KEXT_INFO_LINKAGE
|
||||
#define __KEXT_INFO_VARNAME() __kext_info
|
||||
#define __KEXT_INFO_DEPNAME() __kext_deps
|
||||
#define __KEXT_INFO_FLAGS KEXT_NONE
|
||||
#define __KEXT_INFO_ALIGNMENT 0x80
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define DEFINE_KEXT(ident, online, offline, ...) \
|
||||
static const char *__KEXT_INFO_DEPNAME()[] = { \
|
||||
__VA_ARGS__, NULL \
|
||||
}; \
|
||||
static struct kext_info __section(".kextinfo") __aligned(__KEXT_INFO_ALIGNMENT) __used __KEXT_INFO_VARNAME() = { \
|
||||
__KEXT_INFO_FLAGS, \
|
||||
ident, \
|
||||
online, \
|
||||
offline, \
|
||||
__KEXT_INFO_DEPNAME(), \
|
||||
}
|
||||
#else
|
||||
#define DEFINE_KEXT(ident, online, offline, ...) \
|
||||
static const char *__KEXT_INFO_DEPNAME()[] = { \
|
||||
__VA_ARGS__, NULL \
|
||||
}; \
|
||||
static struct kext_info __section(".kextinfo") __aligned(__KEXT_INFO_ALIGNMENT) __used __KEXT_INFO_VARNAME() = { \
|
||||
.k_flags = __KEXT_INFO_FLAGS, \
|
||||
.k_ident = ident, \
|
||||
.k_online = online, \
|
||||
.k_offline = offline, \
|
||||
.k_dependencies = __KEXT_INFO_DEPNAME(), \
|
||||
}
|
||||
#endif
|
||||
|
||||
struct kext;
|
||||
|
||||
enum kext_flags {
|
||||
KEXT_NONE = 0x00u,
|
||||
KEXT_INTERNAL = 0x01u,
|
||||
KEXT_ONLINE = 0x02u,
|
||||
};
|
||||
|
||||
struct kext_info {
|
||||
enum kext_flags k_flags;
|
||||
char k_ident[KEXT_IDENT_MAX];
|
||||
kern_status_t(*k_online)(struct kext *);
|
||||
kern_status_t(*k_offline)(struct kext *);
|
||||
const char **k_dependencies;
|
||||
};
|
||||
|
||||
struct kext {
|
||||
struct object k_base;
|
||||
enum kext_flags k_flags;
|
||||
char k_ident[KEXT_IDENT_MAX];
|
||||
uint64_t k_ident_hash;
|
||||
struct btree_node k_node;
|
||||
|
||||
kern_status_t(*k_online)(struct kext *);
|
||||
kern_status_t(*k_offline)(struct kext *);
|
||||
|
||||
unsigned int k_nr_dependencies;
|
||||
struct kext **k_dependencies;
|
||||
};
|
||||
|
||||
extern kern_status_t scan_internal_kexts(void);
|
||||
extern kern_status_t bring_internal_kexts_online(void);
|
||||
|
||||
extern kern_status_t init_kernel_kext(void);
|
||||
extern struct kext *kernel_kext(void);
|
||||
|
||||
extern kern_status_t kext_cache_init(void);
|
||||
extern struct kext *kext_alloc(void);
|
||||
extern void kext_release(struct kext *kext);
|
||||
extern kern_status_t kext_register(struct kext *kext);
|
||||
extern struct kext *kext_get_by_id(const char *ident);
|
||||
extern kern_status_t kext_bring_online(struct kext *kext);
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef MANGO_OBJECT_H_
|
||||
#define MANGO_OBJECT_H_
|
||||
|
||||
#include <mango/flags.h>
|
||||
#include <mango/locks.h>
|
||||
#include <mango/status.h>
|
||||
#include <mango/flags.h>
|
||||
#include <mango/vm.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OBJECT_MAGIC 0xBADDCAFE
|
||||
#define OBJECT_MAGIC 0xBADDCAFE
|
||||
#define OBJECT_NAME_MAX 64
|
||||
#define OBJECT_PATH_MAX 256
|
||||
|
||||
#define OBJECT_CAST(to_type, to_type_member, p) \
|
||||
#define OBJECT_CAST(to_type, to_type_member, p) \
|
||||
((to_type *)((uintptr_t)p) - offsetof(to_type, to_type_member))
|
||||
#define OBJECT_C_CAST(c_type, c_type_member, obj_type, objp) \
|
||||
OBJECT_IS_TYPE(objp, obj_type) ? OBJECT_CAST(c_type, c_type_member, (objp)) : NULL
|
||||
#define OBJECT_IS_TYPE(obj, type_ptr) \
|
||||
((obj)->ob_type == (type_ptr))
|
||||
#define OBJECT_C_CAST(c_type, c_type_member, obj_type, objp) \
|
||||
OBJECT_IS_TYPE(objp, obj_type) \
|
||||
? OBJECT_CAST(c_type, c_type_member, (objp)) : NULL
|
||||
#define OBJECT_IS_TYPE(obj, type_ptr) ((obj)->ob_type == (type_ptr))
|
||||
|
||||
struct object;
|
||||
struct object_attrib;
|
||||
@@ -30,22 +30,7 @@ enum object_type_flags {
|
||||
};
|
||||
|
||||
struct object_ops {
|
||||
kern_status_t(*open)(struct object *obj);
|
||||
kern_status_t(*close)(struct object *obj);
|
||||
kern_status_t(*read)(struct object *obj, void *p, size_t off, size_t *r, mango_flags_t flags);
|
||||
kern_status_t(*write)(struct object *obj, const void *p, size_t off, size_t *w, mango_flags_t flags);
|
||||
kern_status_t(*destroy)(struct object *obj);
|
||||
kern_status_t(*query_name)(struct object *obj, char out[OBJECT_NAME_MAX]);
|
||||
kern_status_t(*parse)(struct object *obj, const char *path, struct object **out);
|
||||
kern_status_t(*get_named)(struct object *obj, const char *name, struct object **out);
|
||||
kern_status_t(*get_at)(struct object *obj, size_t at, struct object **out);
|
||||
kern_status_t(*read_attrib)(struct object *obj, struct object_attrib *attrib, char *out, size_t max, size_t *r);
|
||||
kern_status_t(*write_attrib)(struct object *obj, struct object_attrib *attrib, const char *s, size_t len, size_t *r);
|
||||
};
|
||||
|
||||
struct object_attrib {
|
||||
char *a_name;
|
||||
struct queue_entry a_list;
|
||||
kern_status_t (*destroy)(struct object *obj);
|
||||
};
|
||||
|
||||
struct object_type {
|
||||
@@ -55,7 +40,6 @@ struct object_type {
|
||||
unsigned int ob_header_offset;
|
||||
struct vm_cache ob_cache;
|
||||
struct queue_entry ob_list;
|
||||
struct queue ob_attrib;
|
||||
struct object_ops ob_ops;
|
||||
};
|
||||
|
||||
@@ -65,7 +49,6 @@ struct object {
|
||||
spin_lock_t ob_lock;
|
||||
unsigned int ob_refcount;
|
||||
unsigned int ob_handles;
|
||||
struct queue ob_attrib;
|
||||
struct queue_entry ob_list;
|
||||
} __aligned(sizeof(long));
|
||||
|
||||
@@ -73,14 +56,6 @@ extern kern_status_t object_bootstrap(void);
|
||||
extern kern_status_t object_type_register(struct object_type *p);
|
||||
extern kern_status_t object_type_unregister(struct object_type *p);
|
||||
|
||||
extern struct object_namespace *global_namespace(void);
|
||||
extern struct object_namespace *object_namespace_create(void);
|
||||
extern struct object *ns_header(struct object_namespace *ns);
|
||||
extern kern_status_t object_namespace_get_object(struct object_namespace *ns, const char *path, struct object **out);
|
||||
extern kern_status_t object_namespace_create_link(struct object_namespace *ns, const char *linkpath, struct object *dest);
|
||||
extern kern_status_t object_publish(struct object_namespace *ns, const char *path, struct object *obj);
|
||||
extern kern_status_t object_unpublish(struct object_namespace *ns, struct object *obj);
|
||||
|
||||
extern struct object *object_create(struct object_type *type);
|
||||
extern struct object *object_ref(struct object *obj);
|
||||
extern void object_deref(struct object *obj);
|
||||
@@ -88,28 +63,6 @@ extern void object_lock(struct object *obj);
|
||||
extern void object_unlock(struct object *obj);
|
||||
extern void object_lock_irqsave(struct object *obj, unsigned long *flags);
|
||||
extern void object_unlock_irqrestore(struct object *obj, unsigned long flags);
|
||||
static inline kern_status_t object_get(const char *path, struct object **out)
|
||||
{
|
||||
return object_namespace_get_object(global_namespace(), path, out);
|
||||
}
|
||||
extern kern_status_t object_read(struct object *obj, void *p, size_t offset, size_t max, size_t *nr_read, mango_flags_t flags);
|
||||
extern kern_status_t object_write(struct object *obj, const void *p, size_t offset, size_t max, size_t *nr_written, mango_flags_t flags);
|
||||
extern kern_status_t object_get_child_named(struct object *obj, const char *name, struct object **out);
|
||||
extern kern_status_t object_get_child_at(struct object *obj, size_t at, struct object **out);
|
||||
extern kern_status_t object_query_name(struct object *obj, char name[OBJECT_NAME_MAX]);
|
||||
|
||||
extern struct object *set_create(const char *name);
|
||||
extern kern_status_t set_add_object(struct object *set, struct object *obj);
|
||||
extern kern_status_t set_remove_object(struct object *set, struct object *obj);
|
||||
extern bool object_is_set(struct object *obj);
|
||||
|
||||
extern struct object *link_create(const char *name, struct object *dest);
|
||||
extern struct object *link_read_ptr(struct object *link);
|
||||
extern bool object_is_link(struct object *obj);
|
||||
|
||||
extern void init_set_objects(void);
|
||||
extern void init_link_objects(void);
|
||||
extern void init_global_namespace(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
#ifndef MANGO_TERMIOS_H_
|
||||
#define MANGO_TERMIOS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define NCCS 32
|
||||
|
||||
#define BRKINT 00000001
|
||||
#define ICRNL 00000002
|
||||
#define IGNBRK 00000004
|
||||
#define IGNCR 00000010
|
||||
#define IGNPAR 00000020
|
||||
#define INLCR 00000040
|
||||
#define INPCK 00000100
|
||||
#define ISTRIP 00000200
|
||||
#define IUCLC 00000400
|
||||
#define IXANY 00001000
|
||||
#define IXOFF 00002000
|
||||
#define IXON 00004000
|
||||
#define PARMRK 00010000
|
||||
|
||||
#define OPOST 00000001
|
||||
#define OLCUC 00000002
|
||||
#define ONLCR 00000004
|
||||
#define OCRNL 00000010
|
||||
#define ONOCR 00000020
|
||||
#define ONLRET 00000040
|
||||
#define NLDLY 00000100
|
||||
#define NL0 00000000
|
||||
#define NL1 00000100
|
||||
#define OFILL 00000200
|
||||
#define CRDLY 00003400
|
||||
#define CR0 00000000
|
||||
#define CR1 00000400
|
||||
#define CR2 00001000
|
||||
#define CR3 00002000
|
||||
#define TABDLY 00034000
|
||||
#define TAB0 00000000
|
||||
#define TAB1 00004000
|
||||
#define TAB2 00010000
|
||||
#define TAB3 00020000
|
||||
#define BSDLY 00040000
|
||||
#define BS0 00000000
|
||||
#define BS1 00040000
|
||||
#define VTDLY 00100000
|
||||
#define VT0 00000000
|
||||
#define VT1 00100000
|
||||
#define FFDLY 00200000
|
||||
#define FF0 00000000
|
||||
#define FF1 00200000
|
||||
|
||||
#define B0 0
|
||||
#define B50 50
|
||||
#define B75 75
|
||||
#define B110 110
|
||||
#define B134 134
|
||||
#define B150 150
|
||||
#define B200 200
|
||||
#define B300 300
|
||||
#define B600 600
|
||||
#define B1200 1200
|
||||
#define B1800 1800
|
||||
#define B2400 2400
|
||||
#define B4800 4800
|
||||
#define B9600 9600
|
||||
#define B19200 19200
|
||||
#define B38400 38400
|
||||
|
||||
#define CSIZE 00000007
|
||||
#define CS5 00000000
|
||||
#define CS6 00000001
|
||||
#define CS7 00000002
|
||||
#define CS8 00000004
|
||||
#define CSTOPB 00000010
|
||||
#define CREAD 00000020
|
||||
#define PARENB 00000040
|
||||
#define PARODD 00000100
|
||||
#define HUPCL 00000200
|
||||
#define CLOCAL 00000400
|
||||
|
||||
#define ECHO 00000001
|
||||
#define ECHOE 00000002
|
||||
#define ECHOK 00000004
|
||||
#define ECHONL 00000010
|
||||
#define ICANON 00000020
|
||||
#define IEXTEN 00000040
|
||||
#define ISIG 00000100
|
||||
#define NOFLSH 00000200
|
||||
#define TOSTOP 00000400
|
||||
#define XCASE 00001000
|
||||
|
||||
#define TCSANOW 1
|
||||
#define TCSADRAIN 2
|
||||
#define TCSAFLUSH 3
|
||||
|
||||
#define TCIFLUSH 1
|
||||
#define TCOFLUSH 2
|
||||
#define TCIOFLUSH (TCIFLUSH | TCOFLUSH)
|
||||
|
||||
typedef unsigned int speed_t;
|
||||
typedef unsigned int tcflag_t;
|
||||
typedef unsigned char cc_t;
|
||||
|
||||
struct termios {
|
||||
tcflag_t c_iflag;
|
||||
tcflag_t c_oflag;
|
||||
tcflag_t c_cflag;
|
||||
tcflag_t c_lflag;
|
||||
cc_t c_line;
|
||||
cc_t c_cc[NCCS];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,145 +0,0 @@
|
||||
#ifndef MANGO_TTY_H_
|
||||
#define MANGO_TTY_H_
|
||||
|
||||
#include <mango/status.h>
|
||||
#include <mango/device.h>
|
||||
#include <mango/queue.h>
|
||||
#include <mango/object.h>
|
||||
#include <mango/termios.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define TTY_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_CHAR ? (dev)->chr.c_tty : NULL)
|
||||
#define TTY_DRIVER(drv) ((struct tty_driver *)((char *)drv - offsetof(struct tty_driver, tty_base)))
|
||||
|
||||
#define TTY_INPUT_QUEUE_SIZE 256
|
||||
#define TTY_LINE_MAX 4096
|
||||
|
||||
struct kext;
|
||||
|
||||
/* The TTY system.
|
||||
|
||||
TTYs are an enhanced version of the console object. Rather than a simple output
|
||||
device for log messages, TTYs are intended to support fully-featured interactive
|
||||
user sessions, including advanced display manipulation (if applicable) and
|
||||
buffered user input.
|
||||
|
||||
A TTY object is split into 2 parts:
|
||||
- struct tty: This represents the terminal session, and tracks things like the cursor
|
||||
position, input buffer, flags, etc.
|
||||
- struct tty_driver: This is a set of function callbacks that the TTY can use to
|
||||
manipulate the output device. This could represent a char-based framebuffer
|
||||
device, a serial port, etc.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum tty_driver_type {
|
||||
/* For TTYs operating on simple IO devices like serial ports.
|
||||
Allows writing characters, receiving characters, and not much else. */
|
||||
TTY_DRIVER_SIMPLE,
|
||||
/* For TTYs operating on more capable display interfaces.
|
||||
Allows putting characters at arbitrary locations, scrolling, etc */
|
||||
TTY_DRIVER_FULL,
|
||||
};
|
||||
|
||||
/* TTY cursor status. The extra cursor styles are just for completeness,
|
||||
the important one to support (if possible), is TTY_CURSOR_NONE.
|
||||
The others can be interpreted as "just turn on a cursor of any style". */
|
||||
enum tty_cursor {
|
||||
TTY_CURSOR_ULINE,
|
||||
TTY_CURSOR_BLOCK,
|
||||
TTY_CURSOR_NONE,
|
||||
};
|
||||
|
||||
/* direction to use for scrolling. The important one to support is
|
||||
TTY_SCROLL_DOWN for when output overflows the display */
|
||||
enum tty_scroll_dir {
|
||||
TTY_SCROLL_DOWN,
|
||||
TTY_SCROLL_UP,
|
||||
};
|
||||
|
||||
enum tty_modifier_key {
|
||||
TTY_KEY_OTHER = 0x00u,
|
||||
TTY_KEY_CTRL = 0x01u,
|
||||
TTY_KEY_ALT = 0x02u,
|
||||
TTY_KEY_SHIFT = 0x04u,
|
||||
};
|
||||
|
||||
/* character attribute. this could be as simple as VGA's 16-colour palette
|
||||
plus an extra bit for bright, or a full 24-bit RGB value with bold and underline
|
||||
support, depending on what the driver supports. */
|
||||
typedef uint64_t tty_attrib_t;
|
||||
|
||||
struct tty_driver_ops {
|
||||
void (*tty_init)(struct device *dev);
|
||||
void (*tty_deinit)(struct device *dev);
|
||||
void (*tty_clear)(struct device *dev, int x, int y, int width, int height);
|
||||
void (*tty_putc)(struct device *dev, int c, int xpos, int ypos, tty_attrib_t attrib);
|
||||
void (*tty_set_cursor)(struct device *dev, enum tty_cursor cur);
|
||||
void (*tty_move_cursor)(struct device *dev, int x, int y);
|
||||
void (*tty_scroll)(struct device *dev, enum tty_scroll_dir dir, int lines);
|
||||
};
|
||||
|
||||
struct tty_driver {
|
||||
struct driver tty_base;
|
||||
|
||||
char tty_name[16];
|
||||
enum tty_driver_type tty_type;
|
||||
struct queue_entry tty_head;
|
||||
|
||||
struct tty_driver_ops *tty_ops;
|
||||
};
|
||||
|
||||
struct tty_ldisc {
|
||||
char name[OBJECT_NAME_MAX];
|
||||
kern_status_t(*read)(struct device *, void *, size_t, size_t *, mango_flags_t);
|
||||
void(*write)(struct device *, const struct input_event *);
|
||||
};
|
||||
|
||||
struct tty_device {
|
||||
unsigned int tty_xcells, tty_ycells;
|
||||
unsigned int tty_xcur, tty_ycur;
|
||||
struct termios tty_config;
|
||||
tty_attrib_t tty_curattrib;
|
||||
|
||||
enum tty_modifier_key tty_modstate;
|
||||
|
||||
struct tty_ldisc *tty_ldisc;
|
||||
|
||||
/* input characters processed from tty_events, returned by tty_read() */
|
||||
struct ringbuffer tty_input;
|
||||
char *tty_linebuf;
|
||||
};
|
||||
|
||||
extern void register_tty_console(void);
|
||||
extern void redirect_printk_to_tty(struct device *dest);
|
||||
|
||||
extern kern_status_t tty_bootstrap(void);
|
||||
extern struct tty_ldisc *tty_default_line_discipline(void);
|
||||
|
||||
extern struct device *tty_device_create(void);
|
||||
extern kern_status_t tty_device_register(struct device *dev, struct tty_driver *owner, struct device *parent);
|
||||
|
||||
extern void tty_set_foreground(struct device *tty);
|
||||
extern kern_status_t tty_connect_foreground_input_device(struct device *input);
|
||||
|
||||
extern struct tty_driver *tty_driver_create(struct kext *self, const char *name);
|
||||
extern kern_status_t tty_driver_destroy(struct tty_driver *drv);
|
||||
extern kern_status_t tty_driver_register(struct tty_driver *drv);
|
||||
extern kern_status_t tty_driver_unregister(struct tty_driver *drv);
|
||||
static inline struct driver *tty_driver_base(struct tty_driver *drv)
|
||||
{
|
||||
return &drv->tty_base;
|
||||
}
|
||||
|
||||
extern kern_status_t tty_read(struct device *tty, void *buf, size_t offset, size_t max, size_t *nr_read, mango_flags_t flags);
|
||||
extern kern_status_t tty_write(struct device *tty, const void *buf, size_t offset, size_t len, size_t *nr_written, mango_flags_t flags);
|
||||
extern kern_status_t tty_report_event(struct device *tty, const struct input_event *ev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user