/*** UPDATE MOUSE FOCUS ***/ static void update_mfocus(void) { static EVENT event; WIDGET *new_mfocus = NULL; if (press_cnt != 0) return; /* FIXME: scr->find must be added here! */ new_mfocus = curr_scr->gen->find((WIDGET *)curr_scr, curr_mx, curr_my); if (new_mfocus == curr_mfocus) return; if (curr_mfocus) { curr_mfocus->gen->set_mfocus(curr_mfocus, 0); if (curr_mfocus->wd->flags & WID_FLAGS_HIGHLIGHT) curr_mfocus->gen->update(curr_mfocus); event.time = l4re_kip()->clock; event.type = EV_WINDOW; event.value = 0; curr_mfocus->gen->handle_event(curr_mfocus, &event, NULL); curr_mfocus->gen->dec_ref(curr_mfocus); } if (new_mfocus) { new_mfocus->gen->set_mfocus(new_mfocus, 1); if (new_mfocus->wd->flags & WID_FLAGS_HIGHLIGHT) new_mfocus->gen->update(new_mfocus); event.time = l4re_kip()->clock; event.type = EV_WINDOW; event.value = 1; new_mfocus->gen->handle_event(new_mfocus, &event, NULL); new_mfocus->gen->inc_ref(new_mfocus); } curr_mfocus = new_mfocus; }
int con_hw_init(unsigned short xres, unsigned short yres, unsigned char *bits, unsigned short bpl, l4_addr_t vid_mem_addr, l4_size_t vid_mem_size, con_accel_t *accel, l4_uint8_t **map_vid_mem_addr) { if (init_done) return -L4_EINVAL; l4_calibrate_tsc(l4re_kip()); hw_vid_mem_addr = vid_mem_addr; hw_vid_mem_size = vid_mem_size; hw_xres = xres; hw_yres = yres; hw_bits = *bits; hw_bpl = bpl; #ifdef ARCH_x86 if (l4util_kip_kernel_is_ux(l4re_kip())) { printf("Tuning for Fiasco-UX\n"); if (ux_probe(accel)) return -L4_ENODEV; *map_vid_mem_addr = (void*)hw_map_vid_mem_addr; *bits = hw_bits; return 0; } #endif radeon_register(); ati128_register(); ati_register(); intel_register(); matrox_register(); riva_register(); savage_register(); vmware_register(); if (pci_probe(accel)==0) { /* set by probe functions */ printf("Backend scaler: %s, color keying: %s\n", (accel->caps & (ACCEL_FAST_CSCS_YV12|ACCEL_FAST_CSCS_YUY2)) ? (accel->caps & ACCEL_FAST_CSCS_YV12) ? "YV12" : "YUY2" : "no", (accel->caps & ACCEL_COLOR_KEY) ? "yes" : "no"); *map_vid_mem_addr = (void*)hw_map_vid_mem_addr; *bits = hw_bits; // accel->caps &= ~(ACCEL_FAST_CSCS_YV12|ACCEL_FAST_CSCS_YUY2); return 0; } return -L4_ENODEV; }
int main(void) { l4_kernel_info_t *kip = l4re_kip(); struct l4_vhw_descriptor *vhw; int i; if (!kip) { printf("KIP not available!\n"); return 1; } if (!l4util_kip_kernel_is_ux(kip)) { printf("This example is for Fiasco-UX only.\n"); return 1; } vhw = l4_vhw_get(kip); printf("kip at %p, vhw at %p\n", kip, vhw); printf("magic: %08x, version: %08x, count: %02d\n", vhw->magic, vhw->version, vhw->count); for (i = 0; i < vhw->count; i++) print_entry(l4_vhw_get_entry(vhw, i)); return 0; }
static int mono_clock_gettime(struct timespec *tp) { uint64_t clock; clock = l4re_kip()->clock; tp->tv_sec = clock / 1000000; tp->tv_nsec = (clock % 1000000) * 1000; return 0; }
unsigned long get_cpu_khz (void) { l4_kernel_info_t *kip = l4re_kip(); if(kip) return kip->frequency_cpu; else { printf("Can't map KIP to local place.\n"); enter_kdebug("KIP failed"); } return 0; }
libc_backend_rt_clock_gettime(struct timespec *tp) { uint64_t clock; clock = l4re_kip()->clock; clock += __libc_l4_rt_clock_offset; tp->tv_sec = clock / 1000000; tp->tv_nsec = (clock % 1000000) * 1000; return 0; }
virtual void print() const{ double freq = l4re_kip()->frequency_cpu; // kHz freq /= 1000.0; // MHz (ticks per µs) double sum = (double)_sum / freq; double sumsq = (double)_sumsq / (freq * freq); double mean = sum/(double)_count; double var = (sumsq/(double)_count) - (mean * mean); double dev = 0;//sqrt(var); double min = (double)_min / freq; double max = (double)_max / freq; printf("%s: N:%llu abs:%f min:%f avg:%f max:%f var:%f dev:%f\n" , _name.c_str(), _count, sum, min, mean, max, var, dev); }
/*** TICK CALLBACK THAT IS CALLED FOR EVERY REPEATED KEY ***/ static int tick_handle_repeat(void *arg) { long keycode = (long)arg; EVENT key_repeat_event; if (curr_keystate != USERSTATE_KEY_REPEAT || curr_keycode != keycode) return 0; key_repeat_event.time = l4re_kip()->clock; key_repeat_event.type = EV_KEY; key_repeat_event.code = curr_keycode; key_repeat_event.value = 2; // repeat if (curr_window) { WIDGET *cw = curr_window->win->get_kfocus(curr_window); if (cw) cw->gen->handle_event(cw, &key_repeat_event, NULL); } return 1; }
int main(void) { l4_msgtag_t tag; #ifdef MEASURE l4_cpu_time_t s, e; #endif l4_utcb_t *u = l4_utcb(); l4_exc_regs_t exc; l4_umword_t mr0, mr1; printf("Alien feature testing\n"); l4_debugger_set_object_name(l4re_env()->main_thread, "alientest"); /* Start alien thread */ if (l4_is_invalid_cap(alien = l4re_util_cap_alloc())) return 1; l4_touch_rw(alien_thread_stack, sizeof(alien_thread_stack)); tag = l4_factory_create_thread(l4re_env()->factory, alien); if (l4_error(tag)) return 1; l4_debugger_set_object_name(alien, "alienth"); l4_thread_control_start(); l4_thread_control_pager(l4re_env()->main_thread); l4_thread_control_exc_handler(l4re_env()->main_thread); l4_thread_control_bind((l4_utcb_t *)l4re_env()->first_free_utcb, L4RE_THIS_TASK_CAP); l4_thread_control_alien(1); tag = l4_thread_control_commit(alien); if (l4_error(tag)) return 2; tag = l4_thread_ex_regs(alien, (l4_umword_t)alien_thread, (l4_umword_t)alien_thread_stack + sizeof(alien_thread_stack), 0); if (l4_error(tag)) return 3; l4_sched_param_t sp = l4_sched_param(1, 0); tag = l4_scheduler_run_thread(l4re_env()->scheduler, alien, &sp); if (l4_error(tag)) return 4; #ifdef MEASURE l4_calibrate_tsc(l4re_kip()); #endif /* Pager/Exception loop */ if (l4_msgtag_has_error(tag = l4_ipc_receive(alien, u, L4_IPC_NEVER))) { printf("l4_ipc_receive failed"); return 1; } memcpy(&exc, l4_utcb_exc(), sizeof(exc)); mr0 = l4_utcb_mr()->mr[0]; mr1 = l4_utcb_mr()->mr[1]; for (;;) { #ifdef MEASURE s = l4_rdtsc(); #endif if (l4_msgtag_is_exception(tag)) { #ifndef MEASURE printf("PC=%08lx SP=%08lx Err=%08lx Trap=%lx, %s syscall, SC-Nr: %lx\n", l4_utcb_exc_pc(&exc), exc.sp, exc.err, exc.trapno, (exc.err & 4) ? " after" : "before", exc.err >> 3); #endif tag = l4_msgtag((exc.err & 4) ? 0 : L4_PROTO_ALLOW_SYSCALL, L4_UTCB_EXCEPTION_REGS_SIZE, 0, 0); } else printf("Umm, non-handled request (like PF): %lx %lx\n", mr0, mr1); memcpy(l4_utcb_exc(), &exc, sizeof(exc)); /* Reply and wait */ if (l4_msgtag_has_error(tag = l4_ipc_call(alien, u, tag, L4_IPC_NEVER))) { printf("l4_ipc_call failed\n"); return 1; } memcpy(&exc, l4_utcb_exc(), sizeof(exc)); mr0 = l4_utcb_mr()->mr[0]; mr1 = l4_utcb_mr()->mr[1]; #ifdef MEASURE e = l4_rdtsc(); printf("time %lld\n", l4_tsc_to_ns(e - s)); #endif }
int ux_probe(con_accel_t *accel) { struct l4_vhw_descriptor *vhw; struct l4_vhw_entry *vhwe; if (!l4util_kip_kernel_is_ux(l4re_kip())) return -L4_ENODEV; if (l4io_lookup_device("L4UXfb", NULL, 0, 0)) { printf("WARNING: Running under Fiasco-UX and no 'L4UXfb' device found, can only use polling mode!\n"); return -L4_ENODEV; } printf("Found Fiasco-UX Framebuffer\n"); if (!(vhw = l4_vhw_get(l4re_kip()))) return -L4_ENODEV; if (!(vhwe = l4_vhw_get_entry_type(vhw, L4_TYPE_VHW_FRAMEBUFFER))) return -L4_ENODEV; ux_con_pid = vhwe->provider_pid; accel->drty = uxScreenUpdate; accel->caps = ACCEL_POST_DIRTY; printf("Found VHW descriptor, provider is %d\n", ux_con_pid); l4_thread_control_start(); l4_thread_control_ux_host_syscall(1); l4_thread_control_commit(l4re_env()->main_thread); /* The update thread needs to run with the same priority than as the vc * threads (otherwise the screen won't be updated) */ { pthread_t update_tid; pthread_attr_t a; struct sched_param sp; pthread_attr_init(&a); sp.sched_priority = 0x70; pthread_attr_setschedpolicy(&a, SCHED_L4); pthread_attr_setschedparam(&a, &sp); pthread_attr_setinheritsched(&a, PTHREAD_EXPLICIT_SCHED); if (pthread_create(&update_tid, &a, updater_thread, NULL)) return -L4_ENOMEM; updater_id = pthread_getl4cap(update_tid); #if 0 update_tid = l4thread_create_long(L4THREAD_INVALID_ID, updater_thread, ".scr-upd", L4THREAD_INVALID_SP, L4THREAD_DEFAULT_SIZE, 0xff, NULL, L4THREAD_CREATE_ASYNC); if (update_tid < 0) { printf("Could not create updater thread.\n"); return -L4_ENOTHREAD; } updater_id = l4thread_l4_id(update_tid); #endif } #if 0 if (hw_vid_mem_addr != vhwe->mem_start || hw_vid_mem_size != vhwe->mem_size) printf("!!! Memory area mismatch "l4_addr_fmt"(%lx) vs. "l4_addr_fmt "(%lx) ... continuing\n", hw_vid_mem_addr, hw_vid_mem_size, vhwe->mem_start, vhwe->mem_size); #endif //map_io_mem(hw_vid_mem_addr, hw_vid_mem_size, 0, "UX video", // (l4_addr_t *)&hw_map_vid_mem_addr); // already mapped by vesa-ds + rm-attach hw_map_vid_mem_addr = hw_vid_mem_addr; return 0; }
static int __init ux_init(void) { struct net_device *netdev; struct ux_private *priv; struct ifreq ifr; l4io_device_handle_t devhandle = l4io_get_root_device(); l4io_device_t iodev; l4io_resource_handle_t reshandle; int irq = -1; int fd = -1; int prov_pid = -1; int err; if (!l4util_kip_kernel_is_ux(l4re_kip())) return 1; printk("UX Ankh driver firing up...\n"); while (!l4io_iterate_devices(&devhandle, &iodev, &reshandle)) { l4io_resource_t res; if (strcmp(iodev.name, "L4UXnet")) continue; while (!l4io_lookup_resource(devhandle, L4IO_RESOURCE_ANY, &reshandle, &res)) { if (res.type == L4IO_RESOURCE_IRQ) irq = res.start; if (res.type == L4IO_RESOURCE_PORT) { fd = res.start; prov_pid = res.end; } } } if (irq == -1 || fd == -1 || prov_pid == -1) { printk(KERN_ERR "uxeth: Could not find L4UXnet device\n"); return 1; } enable_ux_self(); netdev = alloc_etherdev(sizeof(struct ux_private)); if (netdev == NULL) { printk(KERN_ERR "uxeth: could not allocate device!\n"); return 1; } netdev->netdev_ops = &ux_netdev_ops; netdev->dev_addr[0] = 0x04; netdev->dev_addr[1] = 0xEA; netdev->dev_addr[2] = 0xDD; netdev->dev_addr[3] = 0xFF; netdev->dev_addr[4] = 0xFF; netdev->dev_addr[5] = 0xFE; priv = netdev_priv(netdev); netdev->irq = irq; priv->fd = fd; priv->prov_pid = prov_pid; if ((err = register_netdev(netdev))) { printk(KERN_ERR "uxeth: Could not register network device.\n"); free_netdev(netdev); return err; } printk(KERN_INFO "uxeth: Ready (IRQ: %d, fd: %d, prov_pid: %d)\n", irq, fd, prov_pid); return 0; }