Ejemplo n.º 1
1
int main(){
    init_serial();
    printk("f**k\n");
    //mem_test();
	blue_screen();
	hlt();
	return 0;
}
Ejemplo n.º 2
0
static int pf( struct registers *r ) {
    cli();

    uint32_t cr2 = getCR2();
    pde_t *cr3 = (pde_t *) PA2KVA(GET_BASE_ADDRESS(getCR3()));
    pte_t *pte = (pte_t *) PA2KVA(GET_BASE_ADDRESS(cr3[ GET_PD_OFFSET(cr2) ]));

    kprint( r->errcode & 1 ? "Page level protection\n" : "Page not present\n" );
    kprint( r->errcode & 2 ? "Write error\n" : "Read error\n" );
    kprint( r->errcode & 4 ? "User mode\n" : "Supervisor mode\n" );
    kprint( r->errcode & 8 ? "Reserved bits en 1 en PD\n" : "Reserved bits en 0 en PD\n" );
    kprint( r->errcode & 16 ? "Instruction Fetch\n" : "No fue Instruction Fetch\n" );
    kprint( "CR2: 0x%x\nDir: 0x%x:0x%x\n", cr2, r->cs, r->eip );

    if ( r->cs == USER_CS ) {
        kprint( "Matando tarea %d\n", tarea_activa );
        matar_tarea( tarea_activa );
    }

    /*if ( cr2 < KERNEL_MEMMAP ) {
    	kprint ( "PDE Flags: %x\n", cr3[ GET_PD_OFFSET(cr2) ] & 0xF );
    	kprint ( "PTE Flags: %x\n", pte[ GET_PT_OFFSET(cr2) ] & 0xF );
    	if ( r->errcode & 1 ) { // Si estaba presente le arreglo esto.
    		kprint ( "Arreglando.\n" );
    		cr3[ GET_PD_OFFSET(cr2) ] |= PAGE_USER | PAGE_RW;
    		invlpg( GET_BASE_ADDRESS(cr2) );
    		return 0;
    	}
    }*/
    for (;;) hlt();
}
Ejemplo n.º 3
0
int kmain(BootInfo_p BOOTINF)
{
#ifdef DEBUG
	DEBUG_printf("BOS v. 0.0.4\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__);
#endif
	_PMM_init(BOOTINF);
	_VMM_init(BOOTINF);
	_i686_init();
	_TM_init(BOOTINF);

	// Do everything the Kernel Needs to do before sti
	// Note Kernel Thread is Idle Thread once ints are on.
	_TSS_setESP();
#ifdef DEBUG
	DEBUG_printf("BOS v. 0.0.4\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__);
#endif
	sti();
	while(TRUE) {
#ifdef DEBUG_FULL
	DEBUG_print("Idle Thread\n");
#endif
		hlt();
	DEBUG_print("DONE\n");
	}
	return -1;
}
Ejemplo n.º 4
0
//PAGEBREAK: 42
// Per-CPU process scheduler.
// Each CPU calls scheduler() after setting itself up.
// Scheduler never returns.  It loops, doing:
//  - choose a process to run
//  - swtch to start running that process
//  - eventually that process transfers control
//      via swtch back to the scheduler.
void
scheduler(void)
{
  struct proc *p;

  for(;;){
    // Enable interrupts on this processor.
    sti();

    hlt();

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
      if(p->state != RUNNABLE)
        continue;

      // Switch to chosen process.  It is the process's job
      // to release ptable.lock and then reacquire it
      // before jumping back to us.
      proc = p;
      switchuvm(p);
      p->state = RUNNING;
      swtch(&cpu->scheduler, proc->context);
      switchkvm();

      // Process is done running for now.
      // It should have changed its p->state before coming back.
      proc = 0;
    }
    release(&ptable.lock);

  }
}
Ejemplo n.º 5
0
void kernel_start(void){

	/* Initialisation de l'écran et du curseur */
	efface_ecran();
	place_curseur(0,0);

	/* Initialisation des interruptions */
	masque_IRQ(0, false);
	init_traitant_IT(32, traitant_IT_32);

	/* Initialisation de l'horloge */
	set_clock();

	/* Initialisation des processus */
	
	cree_processus("idle", NULL, ELU);
	cree_processus("proc_proc1", proc1, ACTIVABLE);
	cree_processus("proc_proc2", proc2, ACTIVABLE);
	cree_processus("proc_proc3", proc3, ACTIVABLE);

	processus_elu = tab_processus[0];

	
	/* Démarrage du processus par defaut */
	idle();

 	while(1) {
		hlt();
	}
}
Ejemplo n.º 6
0
/* lock given inode with flag I_BUSY
 * read the inode form disk if necessary
 * non-ref inode can not be lock (ref = 0)
 */
void ilock(struct inode *ip) {
    struct buf *bp;
    struct d_inode *d_ip;
    struct super_block sb;

    read_sb(ip->dev, &sb);

    int timeout = 20000;
    while (ip->flags & I_BUSY) {
        timeout--;
        hlt();
    }
    ip->flags |= I_BUSY;

    /* need to be read form disk */
    if (!(ip->flags & I_VALID)) {
        bp = bread(ip->dev, IBLK(sb, ip->ino));
        d_ip = (struct d_inode *)bp->data + (ip->ino - 1)%IPB;

        /* ip -> dip */
        ip->mode = d_ip->mode;
        ip->uid = d_ip->uid;
        ip->size = d_ip->size;
        ip->mtime = d_ip->mtime;
        ip->gid = d_ip->gid;
        ip->nlinks = d_ip->nlinks;

        memcpy(ip->zone, d_ip->zone, sizeof(d_ip->zone));

        brelse(bp);
        ip->flags |= I_VALID;
    }
}
Ejemplo n.º 7
0
// required by the console driver
void
panic(char *s)
{
    cprintf("bootpanic: %s\n", s);
    for (;;)
        hlt();
}
Ejemplo n.º 8
0
Archivo: ec.c Proyecto: jpl888/coreboot
/* Check for recovery mode and ensure EC is in RO */
void google_chromeec_early_init(void)
{
	struct chromeec_command cec_cmd;
	struct ec_response_get_version cec_resp = {{0}};

	cec_cmd.cmd_code = EC_CMD_GET_VERSION;
	cec_cmd.cmd_version = 0;
	cec_cmd.cmd_data_out = &cec_resp;
	cec_cmd.cmd_size_in = 0;
	cec_cmd.cmd_size_out = sizeof(cec_resp);
	google_chromeec_command(&cec_cmd);

	if (cec_cmd.cmd_code ||
	    (recovery_mode_enabled() &&
	     (cec_resp.current_image != EC_IMAGE_RO))) {
		struct ec_params_reboot_ec reboot_ec;
		/* Reboot the EC and make it come back in RO mode */
		reboot_ec.cmd = EC_REBOOT_COLD;
		reboot_ec.flags = 0;
		cec_cmd.cmd_code = EC_CMD_REBOOT_EC;
		cec_cmd.cmd_version = 0;
		cec_cmd.cmd_data_in = &reboot_ec;
		cec_cmd.cmd_size_in = sizeof(reboot_ec);
		cec_cmd.cmd_size_out = 0; /* ignore response, if any */
		printk(BIOS_DEBUG, "Rebooting with EC in RO mode:\n");
		google_chromeec_command(&cec_cmd);
		udelay(1000);
		hard_reset();
		hlt();
	}
}
Ejemplo n.º 9
0
Archivo: game.c Proyecto: jiro789/Orga2
void game_ver_si_termina(){
unsigned char ganador;
        unsigned char haybotines = 0;
        int i;
	for (i = 0; i < BOTINES_CANTIDAD; i++){
            if (botines[i][2] != 0)
                haybotines = 1;
        }
   	if (tiempo_sin_juego < MAX_SIN_CAMBIOS && haybotines){
    	return;
    }
    if(jugadores[1].puntaje < jugadores[0].puntaje){
     	ganador = 0;
        }else{
        ganador = 1;
   	/*}else{
        if(jugadores[0].puntaje < jugadores[1].puntaje){
        	ganador = 1;
        }else{
        	ganador = -1;
        }
 	}
         */}
        //NO EXISTE EL EMPATE, GANA EL JUGADOR 2 EN ESE CASO
        jugador_t jg = jugadores[ganador];
        jugador_t *jp = &jg;
        screen_stop_game_show_winner(jp);
        hlt();
	
}
Ejemplo n.º 10
0
static inline void reset_system(void)
{
	hard_reset();
	while (1) {
		hlt();
	}
}
Ejemplo n.º 11
0
void main(unsigned long bist)
{
	int boot_mode = 0;
	int cbmem_was_initted;
	u32 pm1_cnt;
	u16 pm1_sts;

	if (MCHBAR16(SSKPD) == 0xCAFE) {
		outb(0x6, 0xcf9);
		hlt ();
	}

	struct pei_data pei_data = {
		pei_version: PEI_VERSION,
		mchbar: DEFAULT_MCHBAR,
		dmibar: DEFAULT_DMIBAR,
		epbar: DEFAULT_EPBAR,
		pciexbar: CONFIG_MMCONF_BASE_ADDRESS,
		smbusbar: SMBUS_IO_BASE,
		wdbbar: 0x4000000,
		wdbsize: 0x1000,
		hpet_address: CONFIG_HPET_ADDRESS,
		rcba: DEFAULT_RCBABASE,
		pmbase: DEFAULT_PMBASE,
		gpiobase: DEFAULT_GPIOBASE,
		thermalbase: 0xfed08000,
		system_type: 0, // 0 Mobile, 1 Desktop/Server
		tseg_size: CONFIG_SMM_TSEG_SIZE,
		spd_addresses: { 0xA0, 0x00,0xA2,0x00 },
Ejemplo n.º 12
0
static char get_key() {
    while(!key) hlt();

    char temp = key;
    key = 0;
    return temp;
}
Ejemplo n.º 13
0
static bool nopm_action(PM_STATES state)
{
    switch (state)
    {
        case PM_SOFTOFF: // Implemented by "hack", just as a fallback.
            cli();
            vga_clearScreen();
            kprintf("                                                                                ", 24, 0x20);
            kprintf("                     Your computer can now be switched off.                     ", 25, 0x20);
            kprintf("                                                                                ", 26, 0x20);
            hlt();
            return (false); // Hopefully not reached
        case PM_REBOOT: // We do not use the powermanagement here because its not necessary
        {
            int32_t temp; // A temporary int for storing keyboard info. The keyboard is used to reboot
            do // Flush the keyboard controller
            {
                temp = inportb(0x64);
                if (temp & 1)
                    inportb(0x60);
            }
            while (temp & 2);

            // Reboot
            outportb(0x64, 0xFE);

            return (false); // Hopefully not reached
        }
        default: // Every other state is unreachable without PM
            return (false);
    }
}
Ejemplo n.º 14
0
Archivo: fat.c Proyecto: d33tah/whitix
DWORD FatAccess(struct VfsSuperBlock* sBlock,DWORD clusterNum,int newVal)
{
	struct FatSbInfo* fatInfo=FatGetSbPriv(sBlock);
	DWORD first=0,last=0,retVal=0;
	BYTE *pFirst=NULL,*pLast=NULL;
	struct Buffer* buff,*buff2,*copyBuff,*copyBuff2;
	DWORD i;
	int block;

	if (clusterNum > fatInfo->totalDataSectors)
	{
		KePrint("PANIC: FatAccess : cluster number (%#X) > totalDataSectors from %#X\n",clusterNum,__builtin_return_address(0));
		KernelPanic("FatAccess: cluster number > total data sectors");
		cli(); hlt();
	}

	/* Due to the lovely FAT12 format, where entries can strech over blocks, 
	 * 2 blocks have to be read in in the worst case scenario */

	/* Get the index number into the FAT */
	if (fatInfo->fatType == 12)
	{
		first=clusterNum*3/2;
		last=first+1;
	}else if (fatInfo->fatType == 16)
		last=first=clusterNum*2; /* Never goes over a sector boundary */
	else
		/* FAT32 */
		last = first = clusterNum * 4;

	/* Read in the FAT sector(s) concerned */
	buff=BlockRead(sBlock->sDevice,fatInfo->fatStart+(first/BYTES_PER_SECTOR(sBlock)));
	if (!buff)
	{
		KePrint("Failed to read buffer in FatAccess\n");
		return 0;
	}

	/* Is the entry on the same sector? */
	if ((first/BYTES_PER_SECTOR(sBlock)) == (last/BYTES_PER_SECTOR(sBlock)))
		buff2=buff;
	else{
		buff2=BlockRead(sBlock->sDevice,(fatInfo->fatStart+(first/BYTES_PER_SECTOR(sBlock)))+1);
		if (!buff2)
		{
			BlockFree(buff);
			KePrint("Failed to read buffer 2 in FatAccess\n");
			return 0;
		}
	}

	if (fatInfo->fatType == 12)
	{
		/* Slightly confusing */
		pFirst=&((BYTE*)buff->data)[first % BYTES_PER_SECTOR(sBlock)];
		pLast=&((BYTE*)buff2->data)[(first+1) % BYTES_PER_SECTOR(sBlock)];
		if (clusterNum & 1)
			retVal=((*pFirst >> 4) | (*pLast << 4)) & 0xFFF;
		else
Ejemplo n.º 15
0
void
apm_shutdown(void)
{
    irq_disable();
    out_str("Shutdown");
    for (;;)
        hlt();
}
Ejemplo n.º 16
0
void panic(char *s)
{
    monitor_puts(s);
    while (1)
    {
        hlt();
    }
}
Ejemplo n.º 17
0
static void reboot(void)
{
	unsigned char good = 0x02;
	while (good & 0x02)
		good = inb(0x64);
	outb(0x64, 0xFE);
	hlt();
}
Ejemplo n.º 18
0
void reboot()
{
	uint8_t good = 0x02;
	while (good & 0x02)
		good = inb(0x64);
	outb(0x64, 0xFE);
	hlt();
}
Ejemplo n.º 19
0
bmk_platform_halt(const char *panicstring)
{

	if (panicstring)
		bmk_printf("PANIC: %s\n", panicstring);
	bmk_printf("halted\n");
	for (;;)
		hlt();
}
Ejemplo n.º 20
0
/**
 * _ex_divide_error():
 *
 */
static void		_ex_divide_error(uint32_t	err_code)
{
  printf("#DE - Divide Error\n", 0);

  /* Kill and restart the task. */
  /* XXX: no action at the moment, freeze the sys... */
  while (1)
    hlt();
}
Ejemplo n.º 21
0
/* This function never returns */
void power_shutdown(void)
{
	struct exynos5_power *power =
		samsung_get_base_power();

	clrbits_le32(&power->ps_hold_ctrl, POWER_PS_HOLD_CONTROL_DATA_HIGH);

	hlt();
}
Ejemplo n.º 22
0
/**
 * _ex_general_protection():
 *
 */
static void		_ex_general_protection(uint32_t	err_code)
{
  console_printf("#GP\n", BG_RED | FG_WHITE | FG_INTENSITY);
  printf("#GP - General Protection (%x)\n", err_code);

  /* Kill and restart the task. */
  /* XXX: no action at the moment, freeze the sys... */
  while (1)
    hlt();
}
Ejemplo n.º 23
0
/**
 * _ex_double_fault():
 *
 */
static void		_ex_double_fault(uint32_t	err_code)
{
  console_printf("#DF\n", BG_RED | FG_WHITE | FG_INTENSITY);
  printf("#DF - Double Fault (%x)\n", err_code);

  /* Kill and restart the task. */
  /* XXX: no action at the moment, freeze the sys... */
  while (1)
    hlt();
}
Ejemplo n.º 24
0
void idle()
{
    cree_processus( proc1, "proc1");
    for (;;)
    {
        sti();
        hlt();
        cli();
    }
}
Ejemplo n.º 25
0
// Enter the processors low-power mode waking up after the specified time has
// elapsed.
void timer_sleep(uint32_t ms)
{
    if (!ms) {
        return;
    }

    const uint32_t initial_ticks = ticks;
    while (initial_ticks + ms > ticks) {
        hlt();
    }
}
Ejemplo n.º 26
0
void exception_handler_err(unsigned int code, unsigned int err)
{
	puts("\n"); puts(exceptions[code]); puts(" -> error code: "); puts(bin2string(err));
	switch(code)
	{
		case 14: // page fault
			puts("\nCR2   : "); puts(hex2string(vmx_read_cr2())); puts(" = "); puts(bin2string(vmx_read_cr2())); puts("\n");
			break;
	}
	hlt();
}
Ejemplo n.º 27
0
kbd_key kbd_PopBuffer(){
	kbd_key k;
	while(current_key==0){
		hlt();
	//fill in busy code here	
	}
	stopints();
	current_key--;
	k.scancode=keys[current_key].scancode;
	k.asci=keys[current_key].asci;
	startints();
	return k;
}
Ejemplo n.º 28
0
__export void __idle(void)
{
    if (jiffies() - _IdleTimer < TICKS_TO_IDLE)
	return;

    if (idle_hook_func && idle_hook_func())
	return;			/* Nonzero return = do not idle */

    sti();
    if (NoHalt)
	cpu_relax();
    else
	hlt();
}
Ejemplo n.º 29
0
void main(void)
{
	void *entry;

	console_init();
	exception_init();

	entry = vboot2_verify_firmware();

	if (entry != (void *)-1)
		stage_exit(entry);

	hlt();
}
Ejemplo n.º 30
0
Archivo: ec.c Proyecto: jpl888/coreboot
void google_chromeec_init(void)
{
	struct chromeec_command cec_cmd;
	struct ec_response_get_version cec_resp = {{0}};

	printk(BIOS_DEBUG, "Google Chrome EC: Initializing keyboard.\n");

	google_chromeec_hello();

	cec_cmd.cmd_code = EC_CMD_GET_VERSION;
	cec_cmd.cmd_version = 0;
	cec_cmd.cmd_data_out = &cec_resp;
	cec_cmd.cmd_size_in = 0;
	cec_cmd.cmd_size_out = sizeof(cec_resp);
	google_chromeec_command(&cec_cmd);

	if (cec_cmd.cmd_code) {
		printk(BIOS_DEBUG,
		       "Google Chrome EC: version command failed!\n");
	} else {
		printk(BIOS_DEBUG, "Google Chrome EC: version:\n");
		printk(BIOS_DEBUG, "    ro: %s\n", cec_resp.version_string_ro);
		printk(BIOS_DEBUG, "    rw: %s\n", cec_resp.version_string_rw);
		printk(BIOS_DEBUG, "  running image: %d\n",
		       cec_resp.current_image);
		ec_image_type = cec_resp.current_image;
	}

	if (cec_cmd.cmd_code ||
	    (recovery_mode_enabled() &&
	     (cec_resp.current_image != EC_IMAGE_RO))) {
		struct ec_params_reboot_ec reboot_ec;
		/* Reboot the EC and make it come back in RO mode */
		reboot_ec.cmd = EC_REBOOT_COLD;
		reboot_ec.flags = 0;
		cec_cmd.cmd_code = EC_CMD_REBOOT_EC;
		cec_cmd.cmd_version = 0;
		cec_cmd.cmd_data_in = &reboot_ec;
		cec_cmd.cmd_size_in = sizeof(reboot_ec);
		cec_cmd.cmd_size_out = 0; /* ignore response, if any */
		printk(BIOS_DEBUG, "Rebooting with EC in RO mode:\n");
		google_chromeec_command(&cec_cmd);
		udelay(1000);
		hard_reset();
		hlt();
	}

}