obj: object header is no longer allocated automatically
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <socks/queue.h>
|
||||
#include <socks/status.h>
|
||||
#include <socks/object.h>
|
||||
|
||||
struct device;
|
||||
|
||||
@@ -67,6 +68,7 @@ struct bus_device {
|
||||
};
|
||||
|
||||
struct device {
|
||||
struct object dev_base;
|
||||
enum device_type dev_type;
|
||||
struct device *dev_parent;
|
||||
struct queue dev_children;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SOCKS_KEXT_H_
|
||||
|
||||
#include <socks/status.h>
|
||||
#include <socks/object.h>
|
||||
#include <socks/compiler.h>
|
||||
#include <socks/btree.h>
|
||||
|
||||
@@ -69,6 +70,7 @@ struct kext_info {
|
||||
};
|
||||
|
||||
struct kext {
|
||||
struct object k_base;
|
||||
enum kext_flags k_flags;
|
||||
char k_ident[KEXT_IDENT_MAX];
|
||||
uint64_t k_ident_hash;
|
||||
|
||||
@@ -13,6 +13,13 @@ extern "C" {
|
||||
#define OBJECT_MAGIC 0xBADDCAFE
|
||||
#define OBJECT_NAME_MAX 64
|
||||
|
||||
#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))
|
||||
|
||||
struct object;
|
||||
struct object_attrib;
|
||||
|
||||
@@ -63,6 +70,7 @@ 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_publish(struct object_namespace *ns, const char *path, struct object *obj);
|
||||
extern kern_status_t object_unpublish(struct object_namespace *ns, struct object *obj);
|
||||
@@ -72,8 +80,6 @@ extern struct object *object_ref(struct object *obj);
|
||||
extern void object_deref(struct object *obj);
|
||||
extern void object_lock(struct object *obj, unsigned long *flags);
|
||||
extern void object_unlock(struct object *obj, unsigned long flags);
|
||||
extern void *object_data(struct object *obj);
|
||||
extern struct object *object_header(void *p);
|
||||
static inline kern_status_t object_get(const char *path, struct object **out)
|
||||
{
|
||||
return object_namespace_get_object(global_namespace(), path, out);
|
||||
|
||||
@@ -53,6 +53,8 @@ enum sched_mode {
|
||||
};
|
||||
|
||||
struct task {
|
||||
struct object t_base;
|
||||
|
||||
struct task *t_parent;
|
||||
unsigned int t_id;
|
||||
enum task_state t_state;
|
||||
@@ -66,6 +68,8 @@ struct task {
|
||||
};
|
||||
|
||||
struct thread {
|
||||
struct object thr_base;
|
||||
|
||||
enum thread_state tr_state;
|
||||
enum thread_flags tr_flags;
|
||||
struct task *tr_parent;
|
||||
@@ -131,8 +135,8 @@ static inline void rq_unlock(struct runqueue *rq, unsigned long flags)
|
||||
extern struct runqueue *cpu_rq(unsigned int cpu);
|
||||
|
||||
extern struct task *task_alloc(void);
|
||||
static inline struct task *task_ref(struct task *task) { return (struct task *)object_data(object_ref(object_header(task))); }
|
||||
static inline void task_deref(struct task *task) { object_deref(object_header(task)); }
|
||||
static inline struct task *task_ref(struct task *task) { return OBJECT_CAST(struct task, t_base, object_ref(&task->t_base)); }
|
||||
static inline void task_deref(struct task *task) { object_deref(&task->t_base); }
|
||||
extern struct task *task_from_pid(unsigned int pid);
|
||||
extern struct task *kernel_task(void);
|
||||
extern struct task *idle_task(void);
|
||||
@@ -150,12 +154,12 @@ extern void end_charge_period(void);
|
||||
|
||||
static inline void task_lock_irqsave(struct task *task, unsigned long *flags)
|
||||
{
|
||||
object_lock(object_header(task), flags);
|
||||
object_lock(&task->t_base, flags);
|
||||
}
|
||||
|
||||
static inline void task_unlock_irqrestore(struct task *task, unsigned long flags)
|
||||
{
|
||||
object_unlock(object_header(task), flags);
|
||||
object_unlock(&task->t_base, flags);
|
||||
}
|
||||
|
||||
extern struct thread *thread_alloc(void);
|
||||
|
||||
Reference in New Issue
Block a user