Пример #1
0
t_coord		*check_parenthesis(char *str)
{
	t_coord		*seg;
	int			i;

	i = 0;
	seg = init_seg(0, 0);
	while (str[i])
	{
		if (str[i] == '(')
			seg->x1 = i;
		if (str[i] == ')')
			break ;
		i++;
	}
	seg->x2 = i;
	return (seg);
}
Пример #2
0
void restart() {
    /* Perform some initialization to restart a program */
#ifdef USE_RAMDISK
    /* Read the file with name `argv[1]' into ramdisk. */
    init_ramdisk();
#endif

    /* Read the entry code into memory. */
    load_entry();

    /* Set the initial instruction pointer. */
    cpu.eip = ENTRY_START;

    /* Initialize cache */
    init_caches();

    /* Initialize DRAM. */
    init_ddr3();

    /* Initialize registers */
    cpu.eflags = 0x00000002;

    init_seg();
}
Пример #3
0
void
kentry(void) {
	init_serial();			//初始化串口输出
	init_idt();
	init_timer();
	init_intr();
	init_seg();

	//getKeyCode();

	uint32_t entry = load_umain();
	init_pcb(entry);
	//putchar('A');
	asm volatile("movl %%eax, %%esp" ::"a"(&idle.regs.esp));
	enable_interrupt();
	while(1){
		//putchar('^');
		wait_for_interrupt();
	}

	///p_idle();
	//enter_user_space(entry);
	while(1);
}
Пример #4
0
/*
 * Write a X class file
 * Parameters:
 *      fio     - Pointer to fdinfo block
 *	bufptr	- bit pointer to where data is to go.
 *	nbytes	- Nuber of bytes to be written
 *	stat	- pointer to status return word
 *	fulp	- full or partial write mode flag
 *	ubc	- pointer to unused bit count (not used for IBM)
 */
ssize_t
_gen_xwrite(
    struct fdinfo	*fio,
    bitptr		bufptr,
    size_t		nbytes,
    struct ffsw	*stat,
    int		fulp,
    int		*ubc)
{
    ssize_t ret;
    int64  nbits, bits, moved;
    long left;

    nbits = (uint64)nbytes << 3;
    if (*ubc != 0)
        ERETURN(stat, FDC_ERR_UBC, 0);

    /*
     *	If we've been reading, then try to switch the buffer into write mode.
     */
    if (fio->rwflag == READIN)
    {
        /*
         * Issue an error if we are not positioned at a record
         * boundary.   ffweof would terminate the current record, but
         * _cos_write overwrites the current record.   We need to
         * decide which is the proper approach before permitting this
         * here.
         */
        if (fio->_cnt > 0)
            ERETURN(stat, FDC_ERR_NOTREC, 0);

        ret = gen_xwrard(fio, stat);
        if (ret < 0) return(ERR);
    }

    fio->rwflag = WRITIN;
    moved = 0;
    /*
     *	Check for record size exceeded.
     */
    if ((fio->maxrecsize > 0) && (fio->recbits + nbits) > fio->maxrecsize)
        ERETURN(stat, FDC_ERR_MXREC, 0);

    /*
     *	loop putting data in buffer and building segments
     */

    while (nbits > 0)
    {
        /*
         *		bits tells when data has been moved.  Set it to zero
         *		unless someone moves some data in the loop
         */
        bits = 0;
        /*
         *		initialize a new segment, if needed.
         */
        if (fio->recbits == 0)
        {
            if (init_seg(fio, stat) != 0)
                return(ERR);
        }
        /*
         *		If enough room for bits, put them in the buffer
         */
        left = fio->_ffbufsiz - fio->_cnt;
        if (left >= nbits)
        {
            bits = nbits;
            PUTDATA(bufptr, fio, bits);
            SET_BPTR(bufptr, INC_BPTR(bufptr, bits));
        }
        else
        {
            /*
             *			There is not enough room to put all of the data.
             */
            if (left == 0)
            {
                ret = put_segment(fio, stat, PARTIAL);
                if (ret != 0) return(ERR);
            }
            else
            {
                bits = nbits;
                if (nbits > left) bits = left;
                PUTDATA(bufptr, fio, bits);
                SET_BPTR(bufptr, INC_BPTR(bufptr, bits));
            }
        }
        nbits -= bits;
        moved += bits;
    }

    fio->recbits += moved;
    if (fulp == FULL)
    {
        /*
         *		Watch out for NULL writes!
         */
        if (fio->recbits == 0)
            if (init_seg(fio, stat) != 0)
                return(ERR);
        ret = put_segment(fio, stat, fulp); /* this will be FULL */
        if (ret != 0)
            return(ERR);

        SETSTAT(stat, FFEOR, (uint64)moved >> 3);
        fio->last_recbits = fio->recbits;
        fio->recbits = 0;
    }
    else