Ejemplo n.º 1
0
void delay_boot(uint16_t secs)
{
    uint16_t    i;

    if (!secs)
        return;

    // Set PIT to 1ms ticks
    wait_init();

    printf("Delaying boot for %d seconds:", secs);
    for (i = secs; i > 0; i--)
    {
        printf(" %d", i);
        wait(WAIT_HZ, 0);
    }
    printf("\n");
    // Restore PIT ticks
    wait_uninit();
}
Ejemplo n.º 2
0
int main(void) {
    wait_init();
    char *buf = "Hello world\n";
    float t = lm73.read();
    lcd.print(buf);

    volatile int	value;
    spi.frequency(500000);
    while(*buf) {
    	value = *buf++;
    	spi.write(value);
    }

    while(1) {
    	t = lm73.read();
    	lcd.locate(0, 1);
    	lcd.print("Temp:");
    	lcd.print(t);
        myled = ! myled;
        wait_ms(2000);
    }
    return 0 ;
}
Ejemplo n.º 3
0
int is_sdhc()
{
    int i,r;

    spi_spin();

    r=cmd_CMD8();		// test for SDHC capability
//	printf("cmd_CMD8 response: %d\n",r);
    if(r!=1)
    {
        wait_init();
        return(0);
    }
#if 0
    SPI(0xff);
//	SPI_WAIT();
    r=SPI_READ();
//	printf("CMD8_1 response: %d\n",r);
    SPI(0xff);
//	SPI_WAIT();
    r=SPI_READ();
//	printf("CMD8_2 response: %d\n",r);
    SPI(0xff);
//	SPI_WAIT();
    r=SPI_READ();
    if(r!=1)
    {
        wait_init();
        return(0);
    }

//	printf("CMD8_3 response: %d\n",r);
    SPI(0xff);
//	SPI_WAIT();
    r=SPI_READ();
    if(r!=0xaa)
    {
        wait_init();
        return(0);
    }
#endif
    r=SPI_PUMP();
    if((r&0xffff)!=0x01aa)
    {
        wait_init();
        return(0);
    }

//	printf("CMD8_4 response: %d\n",r);

    SPI(0xff);

    // If we get this far we have a V2 card, which may or may not be SDHC...

    i=50;
    while(--i)
    {
        if(wait_initV2())
        {
            if((r=cmd_CMD58())==0)
            {
                printf("CMD58 %d\n  ",r);
                SPI(0xff);
//				SPI_WAIT();
                r=SPI_READ();
                printf("CMD58_2 %d\n  ",r);
                SPI_PUMP();
//				SPI(0xff);
//				SPI(0xff);
//				SPI(0xff);
//				SPI(0xff);
                if(r&0x40)
                    return(1);
                else
                    return(0);
            }
            else
                printf("CMD58 %d\n  ",r);
        }
        if(i==2)
        {
            printf("SDHC Initialization error!\n");
            return(0);
        }
    }
    puts("Determined SDHC status\n");
    return(0);
}
Ejemplo n.º 4
0
void show_logo(void)
{
    uint16_t    ebda_seg = read_word(0x0040,0x000E);
    uint8_t     f12_pressed = 0;
    uint8_t     scode;
    uint16_t    tmp, i;

    LOGOHDR     *logo_hdr = 0;
    uint8_t     is_fade_in, is_fade_out, uBootMenu;
    uint16_t    logo_time;
    uint16_t    old_mode;


    // Set PIT to 1ms ticks
    wait_init();

    // Get main signature
    tmp = read_logo_word((uint8_t)&logo_hdr->u16Signature);
    if (tmp != 0x66BB)
        goto done;

    // If there is no VBE, just skip this
    if (vesa_get_mode(&old_mode) != 0x004f )
        goto done;

    // Get options
    is_fade_in  = read_logo_byte((uint8_t)&logo_hdr->fu8FadeIn);
    is_fade_out = read_logo_byte((uint8_t)&logo_hdr->fu8FadeOut);
    logo_time   = read_logo_word((uint8_t)&logo_hdr->u16LogoMillies);
    uBootMenu   = read_logo_byte((uint8_t)&logo_hdr->fu8ShowBootMenu);

    // Is Logo disabled?
    if (!is_fade_in && !is_fade_out && !logo_time)
        goto done;

    // Set video mode #0x142 640x480x32bpp
    vesa_set_mode(0x142);

    if (is_fade_in)
    {
        for (i = 0; i <= LOGO_SHOW_STEPS; i++)
        {
            outw(LOGO_IO_PORT, LOGO_CMD_SHOW_BMP | i);
            scode = wait(16 / WAIT_MS, 0);
            if (scode == F12_SCAN_CODE)
            {
                f12_pressed = 1;
                break;
            }
        }
    }
    else
        outw(LOGO_IO_PORT, LOGO_CMD_SHOW_BMP | LOGO_SHOW_STEPS);

    // Wait (interval in milliseconds)
    if (!f12_pressed)
    {
        scode = wait(logo_time / WAIT_MS, 1);
        if (scode == F12_SCAN_CODE)
            f12_pressed = 1;
    }

    // Fade out (only if F12 was not pressed)
    if (is_fade_out && !f12_pressed)
    {
        for (i = LOGO_SHOW_STEPS; i > 0 ; i--)
        {
            outw(LOGO_IO_PORT, LOGO_CMD_SHOW_BMP | i);
            scode = wait(16 / WAIT_MS, 0);
            if (scode == F12_SCAN_CODE)
            {
                f12_pressed = 1;
                break;
            }
        }
    }

done:
    // Clear forced boot drive setting.
    write_byte(ebda_seg, (uint16_t)&EbdaData->uForceBootDevice, 0);

    // Don't restore previous video mode
    // The default text mode should be set up. (defect @bugref{1235})
    set_mode(0x0003);

    // If Setup menu enabled
    if (uBootMenu)
    {
        // If the graphics logo disabled
        if (!is_fade_in && !is_fade_out && !logo_time)
        {
            if (uBootMenu == 2)
                printf("Press F12 to select boot device.\n");

            // if the user has pressed F12 don't wait here
            if (!f12_pressed)
            {
                // Wait for timeout or keystroke
                scode = wait(F12_WAIT_TIME, 1);
                if (scode == F12_SCAN_CODE)
                    f12_pressed = 1;
            }
        }

        // If F12 pressed, show boot menu
        if (f12_pressed)
        {
            uint8_t boot_device = 0;
            uint8_t boot_drive = 0;

            clear_screen();

            // Show menu. Note that some versions of bcc freak out if we split these strings.
            printf("\nVirtualBox temporary boot device selection\n\nDetected Hard disks:\n\n");
            print_detected_harddisks();
            printf("\nOther boot devices:\n f) Floppy\n c) CD-ROM\n l) LAN\n\n b) Continue booting\n");



            // Wait for keystroke
            for (;;)
            {
                do
                {
                    scode = wait(WAIT_HZ, 1);
                } while (scode == 0);

                if (scode == 0x30)
                {
                    // 'b' ... continue
                    break;
                }

                // Check if hard disk was selected
                if ((scode >= 0x02) && (scode <= 0x09))
                {
                    boot_drive = get_boot_drive(scode);

                    /*
                     * 0xff indicates that there is no mapping
                     * from the scan code to a hard drive.
                     * Wait for next keystroke.
                     */
                    if (boot_drive == 0xff)
                        continue;

                    write_byte(ebda_seg, (uint16_t)&EbdaData->uForceBootDrive, boot_drive);
                    boot_device = 0x02;
                    break;
                }

                switch (scode)
                {
                    case 0x21:
                        // Floppy
                        boot_device = 0x01;
                        break;
                    case 0x2e:
                        // CD-ROM
                        boot_device = 0x03;
                        break;
                    case 0x26:
                        // LAN
                        boot_device = 0x04;
                        break;
                }

                if (boot_device != 0)
                    break;
            }

            write_byte(ebda_seg, (uint16_t)&EbdaData->uForceBootDevice, boot_device);

            // Switch to text mode. Clears screen and enables cursor again.
            set_mode(0x0003);
        }
    }

    // Restore PIT ticks
    wait_uninit();

    return;
}