Example #1
0
void process_init()
{
	process_cache = kmem_cache_create("process_cache",
		sizeof(struct process), 32, NULL, NULL);
	if(!process_cache)
		panic("process_init: Not Enough Memory to boot ManRiX\n");

	phash =	(phashtable_t)kmem_alloc(PAGE_SIZE);
	if(!phash)
		panic("process_init: Not Enough Memory to boot ManRiX\n");
	memset(phash, 0, PAGE_SIZE);

	list_init(&kernel_process.threads);
	list_init(&kernel_process.proclist);
	list_init(&kernel_process.child);
	list_init(&kernel_process.sigqueue);
	list_init(&kernel_process.timer);
	kernel_process.parent = kernel;
	list_init(&sysinfo.proclist);
	SPIN_LOCK_INIT(&kernel_process.lock);

	thread_init();
	init_signal();
	id_init();
	fd_init();
	sync_init();
}
Example #2
0
void *file_new(const char *path)
{
	t_file *file = (t_file *) malloc( sizeof( t_file));

	id_init( &file->id, path);

	memset( file->id.name,'\0',_NAME_);
	memset( file->ext,'\0',_EXT_);
	memset( file->path,'\0',_PATH_);

	set_path( file->path, path);

	file->is_relative = 0;
	file->is_directory = 0;
	file->has_extention = 0;
	file->path_type = 0;

	file->data = NULL;
	file->lines = NULL;
	file->file = NULL;

	file->data_size = 0;
	file->tot_line = 0;
	file->dir_count = 0;
	file->exists = 0;

	bzero( file->dirs, FILE_MAX_DIR * _NAME_LONG_);
	bzero( file->dir_path, _PATH_);

	return file;
}
Example #3
0
File: txt.c Project: rvba/minuit
void *txt_new(const char *name)
{
	t_txt *txt=(t_txt *)mem_malloc(sizeof(t_txt));

	id_init(&txt->id, name);

	txt->grid_step=TXT_GRID_STEP;
	txt->grid_size_x=TXT_GRID_SIZE_X;
	txt->grid_size_y=TXT_GRID_SIZE_Y;
	txt->grid_spacing=TXT_GRID_SPACING;
	txt->grid_width=txt->grid_step * (txt->grid_size_x + txt->grid_spacing);
	txt->grid_height=txt->grid_step * (txt->grid_size_y + txt->grid_spacing);

	txt->letter_scale_x=TXT_LETTER_SCALE_X;
	txt->letter_scale_y=TXT_LETTER_SCALE_Y;
	txt->letter_width=txt->grid_width * txt->letter_scale_x;
	txt->letter_height=txt->grid_height * txt->letter_scale_y;
	if(name) txt->width=(float)strlen(name)*txt->letter_width;
	else txt->width=0;
	txt->draw=txt_draw;
	txt->data_change=txt_data_change;
	txt->get_width=txt_get_width;

	txt->use_bitmap_font=1;

	txt_init(txt, name);
	txt->edit = 0;
	
	return txt;
}
Example #4
0
void *viewport_new(const char *name)
{
	t_viewport *viewport = (t_viewport *) mem_malloc(sizeof(t_viewport));

	id_init(&viewport->id, name);

	viewport->width = 0;
	viewport->height = 0;
	viewport->x = 0;
	viewport->y = 0;
	viewport->left = 0;
	viewport->right = 0;
	viewport->bottom = 0;
	viewport->top = 0;
	viewport->near = 0;
	viewport->far = 0;
	viewport->camera = NULL;
	viewport->draw = NULL;
	viewport->show_controls = 0;
	viewport->show_outline = 0;
	viewport->fullscreen = 1;
	viewport->use_fullscreen = 1;
	viewport->use_ui = 1;

	return viewport;
}
Example #5
0
t_osc *osc_new( const char *name)
{
	t_osc *osc = mem_malloc( sizeof( t_osc));
	id_init( &osc->id, name);

	osc->done = 0;

	return osc;
}
Example #6
0
int csp_can_init(uint8_t mode, struct csp_can_config *conf) {

	int ret;
	uint32_t mask;

	/* Initialize packet buffer */
	if (pbuf_init() != 0) {
		csp_log_error("Failed to initialize CAN packet buffers\r\n");
		return CSP_ERR_NOMEM;
	}

	/* Initialize CFP identifier */
	if (id_init() != 0) {
		csp_log_error("Failed to initialize CAN identification number\r\n");
		return CSP_ERR_NOMEM;
	}

	if (mode == CSP_CAN_MASKED) {
		mask = CFP_MAKE_DST((1 << CFP_HOST_SIZE) - 1);
	} else if (mode == CSP_CAN_PROMISC) {
		mask = 0;
		csp_if_can.promisc = 1;
	} else {
		csp_log_error("Unknown CAN mode\r\n");
		return CSP_ERR_INVAL;
	}

	can_rx_queue = csp_queue_create(CSP_CAN_RX_QUEUE_SIZE, sizeof(can_frame_t));
	if (can_rx_queue == NULL) {
		csp_log_error("Failed to create CAN RX queue\r\n");
		return CSP_ERR_NOMEM;
	}

	ret = csp_thread_create(csp_can_rx_task, (signed char *) "CANRX",2048, NULL, 3, &can_rx_task);
	if (ret != 0) {
		csp_log_error("Failed to init CAN RX task\r\n");
		return CSP_ERR_NOMEM;
	}

	/* Initialize CAN driver */
	if (can_init(CFP_MAKE_DST(my_address), mask, csp_tx_callback, csp_rx_callback, conf) != 0) {
		csp_log_error("Failed to initialize CAN driver\r\n");
		return CSP_ERR_DRIVER;
	}

	/* Regsiter interface */
	csp_route_add_if(&csp_if_can);

	return CSP_ERR_NONE;

}
Example #7
0
void
scope_arena_init(ScopeArena* A)
{
    id_init(&A->ids);

    memory_init(&A->selector_scope_properties, hale_megabytes(1), 0);
    memory_init(&A->selectors, hale_megabytes(1), 0);
    // memory_init(&A->data, hale_megabytes(1), 0);
    memory_init(&A->cached_scope_properties, hale_megabytes(1), 0);
    memory_init(&A->cached_scopes, hale_megabytes(1), 0);

    A->selector_compiler = {};
    A->selector_compiler.memory = &A->selectors;
    A->selector_compiler.id_arena = &A->ids;
}
Example #8
0
t_engine *engine_new(const char *name)
{
	t_engine *engine = (t_engine *)mem_malloc(sizeof(t_engine));

	id_init(&engine->id, name);

	engine->processes=lst_new("lst");
	engine->garbage = lst_new("lst");
	engine->with_global_limit=ENGINE_WITH_GLOBAL_LIMIT;
	engine->global_limit = 0;
	engine->global_freq=ENGINE_GLOBAL_FREQ;
	engine->process_count=0;
	engine->process_id = 0;

	return engine;
}
Example #9
0
void main (void){

    CPU_init();
    CPU_extCLK();

    // Get the id (even/odd)
    id_init();

    // Encoder input
    //fps_init();
    
    // uC synchro
    sync_init();

    // Leds!
    led_init();

    // Serial coms, over bluetooth
    serial_init();

    EnableInterrupts;


    /* --------- TEST ---------- *
    FTM2_setMod(0x0200); // clk/2**12 = bus/2**20
    FTM2_init(7); // bus/2**8
    
    FTM2_enableInterrupts(seg);

	SPI_init(SPI_BAUDS,SPI_MASTER|SPI_INVERTCLK);

    // Negated
    LED_OUT_EN = 0;
    LED_OUT_EN_PORT = 1;
    // Rising
    LED_OUT_CLK = 0;
    LED_OUT_CLK_PORT = 1;

    /* -------- /TEST ---------- */

    for(;;){
        // Polls for UART input
    	serial_update();
    	//__RESET_WATCHDOG();	/* feeds the dog */
    }
}
Example #10
0
File: block.c Project: rvba/minuit
void *block_new(const char *name)
{
	t_block *block  = (t_block *) mem_malloc( sizeof( t_block));

	block->cls = NULL;

	vset3i( block->idcol, 0, 0, 0);

	id_init(&block->id, name);
	bzero(block->type,_NAME_);
	
	vset3f( block->pos, 0, 0, 0);
	block->width = 0;
	block->height = 0;

	block->block_state.is_root=0;
	block->block_state.draw_outline=0;
	block->block_state.draw_plugs=0;
	block->block_state.is_mouse_over=0;
	block->block_state.update_geometry=1;
	block->block_state.is_a_loop = 0;
	block->block_state.is_in_rhizome = 0;
	block->block_state.frame_based = 0;
	block->block_state.connecting = 0;
	block->block_state.draw_clone_link = 0;

	block->tot_bricks=0;
	block->rhizome_order = -1;
	block->rhizome_pos = 0;

	block->bricks=NULL;
	block->submenu = NULL;
	block->hover = NULL;
	block->selected = NULL;
	block->rhizome = NULL;
	block->set = NULL;

	block->state = NULL;
	block->clone = NULL;

	block->up = 1;
	block->clones = 0;

	return block;
}
Example #11
0
void *image_new( const char *name)
{
	t_image *image = ( t_image *) mem_malloc( sizeof( t_image));

	id_init( &image->id, name);

	image->width=0;
	image->height=0;
	image->bpp=0;
	image->vlst=NULL;
	image->alpha = 0;
	image->size = 0;
	image->color_type = IMG_COLOR;
	image->data_type = IMG_DATA;
	image->file_type = IMG_FILE;

	return image;
}
Example #12
0
File: vlst.c Project: rvba/minuit
void *vlst_new(const char *name)
{
	t_vlst *vlst=(t_vlst *)mem_malloc(sizeof(t_vlst));

	id_init(&vlst->id, name);

	vlst->type=dt_null;
	vlst->count=0;
	vlst->count_new=0;
	vlst->data=NULL;
	vlst->need_update=0;
	vlst->is_linked=0;
	vlst->link=NULL;
	vlst->ref = NULL;
	vlst->type = dt_null;
	vlst->type_target = dt_null;

	return vlst;
}
Example #13
0
void *screen_new(const char *name)
{
	t_screen *screen=(t_screen *)mem_malloc(sizeof(t_screen));

	id_init(&screen->id, name);

	screen->is_visible=0;
	screen->is_active=0;
	screen->always_active=0;
	screen->always_visible=0;
	screen->zoom=1;
	screen->pan_x=0;
	screen->pan_y=0;
	screen->draw=NULL;
	screen->keymap=NULL;

	screen->blocks = NULL;
	screen->viewports = NULL;
	screen->data = NULL;
	
	return screen;
}
Example #14
0
int main(int argc,char **argv)
{
    int binary = 0,hex = 0;
    const char *output = NULL;
    const char *symbols = NULL;
    const char *flash_security = NULL;
    int c,i;

    error_init();
    id_init();
    code_init();
    cpp_option = alloc_type_n(char *,argc*2);
    while ((c = getopt(argc,argv,"bef:hD:I:m:o:U:V")) != EOF) {
	char opt[] = "-?";

    	switch (c) {

	    case 'b':
		binary = 1;
		break;
	    case 'e':
		allow_extensions = 1;
		break;
	    case 'f':
		if (flash_security)
		    usage(*argv);
		flash_security = optarg;
		break;
	    case 'h':
		hex = 1;
		break;
	    case 'o':
		if (output)
		    usage(*argv);
		output = optarg;
		break;
	    case 'm':
		symbols = optarg;
		break;
	    case 'D':
	    case 'I':
	    case 'U':
		opt[1] = c;
		cpp_option[cpp_options*2] = stralloc(opt);
		cpp_option[cpp_options*2+1] = stralloc(optarg);
		cpp_options++;
		break;
	    case 'V':
		printf("m8cas from m8cutils version %s\n",VERSION);
		exit(0);
	    default:
		usage(*argv);
	}
    }
    if (binary && hex)
	usage(*argv);

    if (cpp_options && !allow_extensions) {
	fprintf(stderr,"CPP options are only supported if using CPP (-e)\n");
	return 1;
    }

    read_protection(flash_security);

    /* move stdin to a safe place, because we may open other files before */
    fd0 = dup(0);
    if (fd0 < 0) {
	perror("dup");
	exit(1);
    }
    (void) close(0);

    if (optind == argc)
	do_file(NULL);
    else {
	for (i = optind; i != argc; i++)
	    do_file(argv[i]);
    }

    resolve();
    if (symbols)
	write_symbols(symbols);
    program_size = text->highest_pc;
    id_cleanup();
    code_cleanup();
    error_cleanup();
    if (!hex)
	for (i = 0; i != security_size; i++)
	    if (security[i]) {
		fprintf(stderr,
		  "output must be Intel HEX for non-zero flash protection\n");
		exit(1);
	    }
    write_file(output ? output : "-",binary,hex);
    return 0;
}