/** * \fn net_rx_vfio(vfile, buf, size) * * Receive a buffer from the device driver. */ static size_t rtl_rx_vfio(struct vfile *file, char *buf, size_t size) { struct device *dev = dev_find_devtype(dev_find_devtype(get_root_device(), virtual_bus), net_core_dev); struct net_buff *buff = (struct net_buff*)buf; buff->raw_vlan = RAW_VLAN; if (dev == NULL) return -E_NULL_PTR; struct vfile *io = dev->open(dev); if (io == NULL) return -E_NULL_PTR; if (buf == NULL) return -E_NULL_PTR; io->read(io, (void*) buf, size); return -E_SUCCESS; }
static TIMER * create_timer_obj(char *name, timer_tick_t tick_handle, void *data) { TIMER *timer = kmalloc(sizeof(*timer)); if(NULL == timer) return timer; memset(timer, 0, sizeof(*timer)); timer->name = name; timer->tick_handle = tick_handle; timer->timer_data = data; timer->config = 0xff; struct device *root = get_root_device(); struct device *dev = kmalloc(sizeof(*dev)); dev_timer_init(dev, root); dev->device_data = timer; timer->id = dev->dev_id; dev_timer_setup_io(dev, &timer_read, &timer_write); return timer; }
/* * Find devices. The system is alive. */ void machine_init() { /* * Set up to use floating point. */ init_fpu(); /* * Find the devices */ probeio(); /* * Find the root device */ get_root_device(); /* * Get the time */ inittodr(); }