PaddingEffect::PaddingEffect() : border_color(0.0f, 0.0f, 0.0f, 0.0f), output_width(1280), output_height(720), top(0), left(0), border_offset_top(0.0f), border_offset_left(0.0f), border_offset_bottom(0.0f), border_offset_right(0.0f) { register_vec4("border_color", (float *)&border_color); register_int("width", &output_width); register_int("height", &output_height); register_float("top", &top); register_float("left", &left); register_float("border_offset_top", &border_offset_top); register_float("border_offset_left", &border_offset_left); register_float("border_offset_bottom", &border_offset_bottom); register_float("border_offset_right", &border_offset_right); register_uniform_vec2("offset", uniform_offset); register_uniform_vec2("scale", uniform_scale); register_uniform_vec2("normalized_coords_to_texels", uniform_normalized_coords_to_texels); register_uniform_vec2("offset_bottomleft", uniform_offset_bottomleft); register_uniform_vec2("offset_topright", uniform_offset_topright); }
FFTPassEffect::FFTPassEffect() : input_width(1280), input_height(720), direction(HORIZONTAL) { register_int("fft_size", &fft_size); register_int("direction", (int *)&direction); register_int("pass_number", &pass_number); register_int("inverse", &inverse); glGenTextures(1, &tex); }
void reg_exceptions(void) { int i; for (i = 0; i < 0x100; i++) { register_int(i, (ulong)undef_int, KERNEL_CS, 0x8E); } register_int(DIV0_INT, (ulong)div0_fault, KERNEL_CS, 0x8E); register_int(GPF_INT, (ulong)gp_fault , KERNEL_CS, 0x8E); register_int(DBL_INT, (ulong)dbl_fault, KERNEL_CS, 0x8E); }
MltInput::MltInput(unsigned width, unsigned height) : m_width(width) , m_height(height) , output_linear_gamma(false) , needs_mipmaps(false) , input(0) , isRGB(true) { register_int("output_linear_gamma", &output_linear_gamma); register_int("needs_mipmaps", &needs_mipmaps); }
FFTInput::FFTInput(unsigned width, unsigned height) : texture_num(0), fft_width(width), fft_height(height), convolve_width(width), convolve_height(height), pixel_data(NULL) { register_int("fft_width", &fft_width); register_int("fft_height", &fft_height); register_uniform_sampler2d("tex", &uniform_tex); }
SliceEffect::SliceEffect() : input_slice_size(1), output_slice_size(1), offset(0), direction(VERTICAL) { register_int("input_slice_size", &input_slice_size); register_int("output_slice_size", &output_slice_size); register_int("offset", &offset); register_int("direction", (int *)&direction); register_uniform_float("output_coord_to_slice_num", &uniform_output_coord_to_slice_num); register_uniform_float("slice_num_to_input_coord", &uniform_slice_num_to_input_coord); register_uniform_float("slice_offset_to_input_coord", &uniform_slice_offset_to_input_coord); register_uniform_float("normalized_offset", &uniform_offset); }
/* * Create a co-processor thread for a virtual kernel. This thread operates * outside of the virtual kernel cpu abstraction and may only make direct * cothread and libc calls. */ cothread_t cothread_create(void (*thr_func)(cothread_t cotd), void (*thr_intr)(cothread_t cotd), void *arg, const char *name) { cothread_t cotd; cotd = kmalloc(sizeof(*cotd), M_DEVBUF, M_WAITOK|M_ZERO); cotd->thr_intr = thr_intr; cotd->thr_func = thr_func; cotd->arg = arg; crit_enter(); pthread_mutex_init(&cotd->mutex, NULL); pthread_cond_init(&cotd->cond, NULL); crit_exit(); cotd->pintr = pthread_self(); cotd->intr_id = register_int(1, (void *)thr_intr, cotd, name, NULL, INTR_MPSAFE, 0); /* * The vkernel's cpu_disable_intr() masks signals. We don't want * our coprocessor thread taking any unix signals :-) */ crit_enter(); cpu_mask_all_signals(); pthread_create(&cotd->pthr, NULL, (void *)cothread_thread, cotd); cpu_unmask_all_signals(); crit_exit(); return(cotd); }
/* * Currently this uses the really grody interface from kern/kern_intr.c * (which really doesn't belong in kern/anything.c). Eventually, all of * the code in kern_intr.c and machdep_intr.c should get moved here, since * this is going to be the official interface. */ static int nexus_setup_intr(device_t bus, device_t child, struct resource *irq, int flags, void (*ihand)(void *), void *arg, void **cookiep, lwkt_serialize_t serializer) { int error, icflags; /* somebody tried to setup an irq that failed to allocate! */ if (irq == NULL) panic("nexus_setup_intr: NULL irq resource!"); *cookiep = 0; icflags = flags; if ((irq->r_flags & RF_SHAREABLE) == 0) icflags |= INTR_EXCL; /* * We depend here on rman_activate_resource() being idempotent. */ error = rman_activate_resource(irq); if (error) return (error); /* * XXX cast the interrupt handler function to an inthand2_t. The * difference is that an additional frame argument is passed which * we do not currently want to expose the BUS subsystem to. */ *cookiep = register_int(irq->r_start, (inthand2_t *)ihand, arg, device_get_nameunit(child), serializer, icflags, rman_get_cpuid(irq)); if (*cookiep == NULL) error = EINVAL; return (error); }
static boolean_t acpi_sci_test(const struct acpi_sci_mode *mode) { void *sci_desc; long last_cnt; FADT_VPRINTF("SCI testing %s/%s\n", intr_str_trigger(mode->sci_trig), intr_str_polarity(mode->sci_pola)); last_cnt = get_interrupt_counter(acpi_sci_irq, 0); machintr_legacy_intr_config(acpi_sci_irq, mode->sci_trig, mode->sci_pola); sci_desc = register_int(acpi_sci_irq, acpi_sci_dummy_intr, NULL, "sci", NULL, INTR_EXCL | INTR_CLOCK | INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY, 0); DELAY(100 * 1000); unregister_int(sci_desc, 0); if (get_interrupt_counter(acpi_sci_irq, 0) - last_cnt < 20) { acpi_sci_trig = mode->sci_trig; acpi_sci_pola = mode->sci_pola; kprintf("ACPI FADT: SCI select %s/%s\n", intr_str_trigger(acpi_sci_trig), intr_str_polarity(acpi_sci_pola)); return TRUE; } return FALSE; }
int main(int argc,char **argv) { int i; //iterator pid *x,*y,*z; //structs representing 3 pid controllers imu_t *imu; fd_set net_set; double oldmag,magdiff; struct timeval timeout; int axes[4]={0,0,0,0}; int x_adjust,y_adjust,z_adjust; int sock = init_net(); register_int(); x=init_pid(3500,000,000); y=init_pid(3400,000,1000); z=init_pid(000,000,000); timeout.tv_sec=0; timeout.tv_usec=REFRESH_TIME; for(i=0;i<4;i++) { //initialize PWM modules motors[i]=init_pwm(i); } imu = init_imu(); update_imu(imu); oldmag=imu->mpu.fusedEuler[VEC3_Z] * RAD_TO_DEGREE; while(1) { ////printf("loop\n"); FD_ZERO(&net_set); FD_SET(sock,&net_set); if(select(sock+1,&net_set,(fd_set *) 0,(fd_set *) 0, &timeout)==1) { ////printf("reading from the socket\n"); //read from sock if(!update_axis(sock,axes)) { break; } } else { ////printf("reading from the imu\n"); //update imu update_imu(imu); timeout.tv_sec=0; timeout.tv_usec=REFRESH_TIME; magdiff=imu->mpu.fusedEuler[VEC3_Z] * RAD_TO_DEGREE-oldmag; if(magdiff>300) { magdiff-=360; } if(magdiff<-300) { magdiff+=360; } x_adjust = update_pid(x,0/*axes[1]*.00061*/,imu->mpu.fusedEuler[VEC3_X] * RAD_TO_DEGREE); y_adjust = update_pid(y,0/*axes[2]*.00061*/,imu->mpu.fusedEuler[VEC3_Y] * RAD_TO_DEGREE); //printf("X axis value: %lf\n",imu->mpu.fusedEuler[VEC3_X]*RAD_TO_DEGREE); //printf("Y axis value: %lf\n",imu->mpu.fusedEuler[VEC3_Y]*RAD_TO_DEGREE); z_adjust = update_pid(z,axes[3]*.00061,magdiff); oldmag=imu->mpu.fusedEuler[VEC3_Z] * RAD_TO_DEGREE; set_duty(motors[0],900000+axes[0]*16-z_adjust-y_adjust+x_adjust); set_duty(motors[1],900000+axes[0]*16+z_adjust-y_adjust-x_adjust); set_duty(motors[2],900000+axes[0]*16-z_adjust+y_adjust-x_adjust); set_duty(motors[3],900000+axes[0]*16+z_adjust+y_adjust+x_adjust); } } exit_fxn(0); }
LumaMixEffect::LumaMixEffect() : transition_width(1.0f), progress(0.5f), inverse(0) { register_float("transition_width", &transition_width); register_float("progress", &progress); register_int("inverse", &inverse); register_uniform_bool("bool_inverse", &uniform_inverse); register_uniform_float("progress_mul_w_plus_one", &uniform_progress_mul_w_plus_one); }
FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format_in, GLenum type, unsigned width, unsigned height) : image_format(image_format), type(type), pbo(0), texture_num(0), output_linear_gamma(false), needs_mipmaps(false), width(width), height(height), pitch(width), owns_texture(false), pixel_data(NULL), fixup_swap_rb(false), fixup_red_to_grayscale(false) { assert(type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_BYTE); register_int("output_linear_gamma", &output_linear_gamma); register_int("needs_mipmaps", &needs_mipmaps); register_uniform_sampler2d("tex", &uniform_tex); // Some types are not supported in all GL versions (e.g. GLES), // and will corrected into the right format in the shader. switch (pixel_format_in) { case FORMAT_BGRA_PREMULTIPLIED_ALPHA: pixel_format = FORMAT_RGBA_PREMULTIPLIED_ALPHA; fixup_swap_rb = true; break; case FORMAT_BGRA_POSTMULTIPLIED_ALPHA: pixel_format = FORMAT_RGBA_POSTMULTIPLIED_ALPHA; fixup_swap_rb = true; break; case FORMAT_BGR: pixel_format = FORMAT_RGB; fixup_swap_rb = true; break; case FORMAT_GRAYSCALE: pixel_format = FORMAT_R; fixup_red_to_grayscale = true; break; default: pixel_format = pixel_format_in; break; } }
void init_mouse(void) { void mouse_move(void); void init_mouse_asm(void); init_mouse_asm(); register_int(IRQ0 + IRQ_PS2_MOUSE, (ulong)mouse_move, KERNEL_CS, 0x8E); enable_irq(IRQ_PS2_MOUSE); }
void acpi_sci_config(void) { const struct acpi_sci_mode *mode; KKASSERT(mycpuid == 0); if (acpi_sci_irq < 0) return; if (acpi_sci_trig != INTR_TRIGGER_CONFORM) { KKASSERT(acpi_sci_pola != INTR_POLARITY_CONFORM); machintr_legacy_intr_config(acpi_sci_irq, acpi_sci_trig, acpi_sci_pola); return; } kprintf("ACPI FADT: SCI testing interrupt mode ...\n"); for (mode = acpi_sci_modes; mode->sci_trig != INTR_TRIGGER_CONFORM; ++mode) { void *sci_desc; long last_cnt; FADT_VPRINTF("SCI testing %s/%s\n", intr_str_trigger(mode->sci_trig), intr_str_polarity(mode->sci_pola)); last_cnt = get_interrupt_counter(acpi_sci_irq, 0); machintr_legacy_intr_config(acpi_sci_irq, mode->sci_trig, mode->sci_pola); sci_desc = register_int(acpi_sci_irq, acpi_sci_dummy_intr, NULL, "sci", NULL, INTR_EXCL | INTR_CLOCK | INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY, 0); DELAY(100 * 1000); unregister_int(sci_desc, 0); if (get_interrupt_counter(acpi_sci_irq, 0) - last_cnt < 20) { acpi_sci_trig = mode->sci_trig; acpi_sci_pola = mode->sci_pola; kprintf("ACPI FADT: SCI select %s/%s\n", intr_str_trigger(acpi_sci_trig), intr_str_polarity(acpi_sci_pola)); return; } } kprintf("ACPI FADT: no suitable interrupt mode for SCI, disable\n"); acpi_sci_irq = -1; }
/* * Register an SWI or INTerrupt handler. */ void * register_swi(int intr, inthand2_t *handler, void *arg, const char *name, struct lwkt_serialize *serializer, int cpuid) { if (intr < FIRST_SOFTINT || intr >= MAX_INTS) panic("register_swi: bad intr %d", intr); if (cpuid < 0) cpuid = intr % ncpus; return(register_int(intr, handler, arg, name, serializer, 0, cpuid)); }
void kb_init(void) { void key_int(); char a; register_int(IRQ0 + IRQ_KEYBOARD, (ulong)key_int, KERNEL_CS, 0x8E); enable_irq(IRQ_KEYBOARD); INB(a, 0x64); while (a & 1) { INB(a, 0x60); INB(a, 0x64); } }
void init_rtc(void) { uchar old, n; void rtc_int(void); register_int(IRQ0 + IRQ_CMOS, (ulong)rtc_int, KERNEL_CS, 0x8E); enable_irq(IRQ_CMOS); INB(old, 0x70); OUTB(0x70, 0x8A); INB(n, 0x71); OUTB(0x70, 0x8A); OUTB(0x71, n | 0x40); OUTB(0x70, old); }
ResizeEffect::ResizeEffect() : width(1280), height(720) { register_int("width", &width); register_int("height", &height); }
void init_paging(void) { void page_fault(); register_int(14, (ulong)page_fault, KERNEL_CS, 0x8E); }
void init_processes(void) { void context_switch(); register_int(IRQ0 + IRQ_TIMER, (ulong)context_switch, KERNEL_CS, 0x8E); }
void * register_int_virtual(int intr, inthand2_t *handler, void *arg, const char *name, struct lwkt_serialize *serializer, int intr_flags) { return register_int(intr, handler, arg, name, serializer, intr_flags, 0); }