Example #1
0
/*
 * Init the VM code. 
 */
void
oskit_uvm_redzone_init(void)
{
	oskit_addr_t	addr;

	/*
	 * We use a task gate to catch page faults, since a stack overflow
	 * will try and dump more stuff on the stack. This is the easiest
	 * way to deal with it.
	 */
	if ((addr = (oskit_addr_t)
	            lmm_alloc_aligned(&malloc_lmm, STACKSIZE, 0, 12, 0)) == 0)
		panic(__FUNCTION__": Could not allocate stack\n");

	task_tss.ss0   = KERNEL_DS;
	task_tss.esp0  = addr + STACKSIZE - sizeof(double);
	task_tss.esp   = task_tss.esp0;
	task_tss.ss    = KERNEL_DS;
	task_tss.ds    = KERNEL_DS;
	task_tss.es    = KERNEL_DS;
	task_tss.fs    = KERNEL_DS;
	task_tss.gs    = KERNEL_DS;
	task_tss.cs    = KERNEL_CS;
	task_tss.io_bit_map_offset = sizeof(task_tss);
	task_tss.eip    = (int) double_fault_handler;

	/* Make sure the task is started with interrupts disabled */
	osenv_intr_disable();
	task_tss.eflags = (int) get_eflags();
	osenv_intr_enable();
	
	/* Both TSSs has to know about the page tables */
	task_tss.cr3    = get_cr3();
	base_tss.cr3	= get_cr3();

	/* Initialize the base TSS descriptor.  */
	fill_descriptor(&base_gdt[KERNEL_TRAP_TSS / 8],
			kvtolin(&task_tss), sizeof(task_tss) - 1,
			ACC_PL_K|ACC_TSS|ACC_P, 0);

	/*
	 * NOTE: The task switch will include an extra word on the stack,
	 * pushed by the CPU. The handler will need to be in assembly code
	 * if we care about that value. As it is, the handler routine
	 * stack is going to be slightly messed up, but since the handler
	 * calls panic, it is not a problem right now. 
	 */
	fill_gate(&base_idt[T_DOUBLE_FAULT],
		  0, KERNEL_TRAP_TSS, ACC_TASK_GATE|ACC_P|ACC_PL_K, 0);

	base_idt_load();
	base_gdt_load();
}
Example #2
0
void
linux_restore_flags(unsigned flags)
{
	/*
	 * XXX: Linux drivers only count on the interrupt enable bit
	 * being properly restored.
	 */
	if (flags & IF_FLAG)
		osenv_intr_enable();
	else
		osenv_intr_disable();
}
Example #3
0
static OSKIT_COMDECL
sched_set_share(pfq_sched_t *_sched, pfq_sched_t *_child, float share)
{
	struct pfq_impl *parent = (void *)_sched;
	struct pfq_impl *child = (void *)_child;

	if (parent == NULL || parent->p_count == 0 ||
	    child == NULL || child->p_count == 0)
		return OSKIT_E_INVALIDARG;

	osenv_intr_disable();

	child->p_byte_charge = (float)PFQ_TOTAL_SHARE / share;

	osenv_intr_enable();
	return 0;
}
Example #4
0
static OSKIT_COMDECL
sched_remove_child(pfq_sched_t *_sched, pfq_sched_t *_child)
{
	struct pfq_impl *parent = (void *)_sched;
	struct pfq_impl *child = (void *)_child;

	if (parent == NULL || parent->p_count == 0 ||
	    child == NULL || child->p_count == 0)
		return OSKIT_E_INVALIDARG;

	osenv_intr_disable();

	/* It might or might not be in the virtual queue. */
	oskit_pqueue_remove(parent->p_virtq, (oskit_iunknown_t *)_child);

	child->p_parent = NULL;
	pfq_sched_release(_child);

	osenv_intr_enable();
	return 0;
}
Example #5
0
int
osenv_sleep(osenv_sleeprec_t *sr) 
{
	volatile osenv_sleeprec_t *vsr = sr;
	int was_enabled = osenv_intr_enabled();
	printf("inside osenv_sleep\n");
	osenv_assert(sr);

	/* We won't get anywhere if interrupts aren't enabled! */
	osenv_intr_enable();

	/* Busy-wait until osenv_wakeup() clears the flag in the sleeprec */
	while (vsr->data[1])
		/* NOTHING */;

	/* Restore the original interrupt enable state */
	if (!was_enabled)
		osenv_intr_disable();

	return (int) vsr->data[0];
}
Example #6
0
/*
 * Write system	time back to RTC
 */
void
resettodr()
{
	oskit_timespec_t t = { 0, 0 };
	oskit_time_t 	tm;

	osenv_intr_disable();
	tm = time.tv_sec;
	osenv_intr_enable();

	/* convert from GMT to localtime */
#if 0
	tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
#else
	/* hack for Salt Lake City */
	t.tv_sec -= 7 * 60 *60;
#endif

	t.tv_sec = tm;
	osenv_rtc_set(&t);
}
Example #7
0
/* ARGSUSED */
int
inittodr(time_t base)
{
	oskit_timespec_t	t;

	osenv_intr_disable();

	/* read real time clock */
	osenv_rtc_get(&t);

	/* t.tv_sec now contains the number of seconds, since Jan 1 1970,
	   in the local	time zone */
#if 0
	/* original BSD code to convert to GMT */
	t.tv_sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
#else
	/* hack for Salt Lake City */
	t.tv_sec += 7 * 60 *60;
#endif
	time.tv_sec = t.tv_sec;
	osenv_intr_enable();
	return 0;
}
Example #8
0
/*
 * This is what you're looking for.
 * It does the ARRIVE(i, Packet) algorithm from the paper.
 */
static OSKIT_COMDECL
netio_push(oskit_netio_t *_, oskit_bufio_t *b, oskit_size_t size)
{
	struct netio_impl *n = (void *)_;
	struct pfq_impl *p = n->n_leaf;
	oskit_error_t err;

	assert(n && n->n_count);

	osenv_intr_disable();

	pfq_stats.arrived++;

	/* Append to end of physical queue. */
	err = oskit_queue_enqueue(p->p_packq, b, 0);
	if (err == OSKIT_E_FAIL)
		pfq_stats.qfull++;

	/* Done if p_logicalq is non-empty. */
	if (p->p_logicalq)
		goto done;

	/* Otherwise, this packet becomes the head of the p_logicalq queue. */
	p->p_logicalq = b;
	oskit_bufio_addref(b);

	/* Update start and finish times. */
	_pfq_update_start_finish(p, 0);

	/* Restart our parent if they're not watching T.V. */
	if (! p->p_parent->p_busy)
		_pfq_restart_node(p->p_parent);

 done:
	osenv_intr_enable();
	return 0;
}
Example #9
0
void
linux_cli()
{
	osenv_intr_disable();
}