#include #include #include static struct device *root_device = NULL; static object_type_t device_type = { .ob_name = "device", .ob_size = sizeof(struct device), .ob_ops = { .destroy = NULL, } }; kern_status_t device_init(void) { object_type_register(&device_type); return KERN_OK; } kern_status_t set_root_device(struct device *dev) { if (root_device) { object_deref(object_header(root_device)); } object_ref(object_header(dev)); root_device = dev; return KERN_OK; } struct device *device_alloc(void) { object_t *dev_object = object_create(&device_type); if (!dev_object) { return NULL; } return object_data(dev_object); }