示例#1
0
static int cmd_bios(int argc, char *argv[])
{
	char cmdline[MAX_CMDLINE_LEN];

	if (argc == 1) {
#if (!defined(CONFIG_NAND_NONE) || !defined(CONFIG_NOR_NONE))
		flpart_table_t ptb;
		flprog_get_part_table(&ptb);
#if defined(AMBOOT_DEV_BOOT_CORTEX)
		cmd_cortex_bios(ptb.dev.cmdline, 1);
#else
		bios(ptb.dev.cmdline, 1);
#endif
#else
#if defined(AMBOOT_DEV_BOOT_CORTEX)
		cmd_cortex_bios(NULL, 1);
#else
		bios(NULL, 1);
#endif
#endif
	} else {
		strfromargv(cmdline, sizeof(cmdline), argc - 1, &argv[1]);
#if defined(AMBOOT_DEV_BOOT_CORTEX)
		cmd_cortex_bios(cmdline, 1);
#else
		bios(cmdline, 1);
#endif
	}

	return 0;
}
示例#2
0
unsigned long getExtendedMemorySize()
{
	// Get extended memory size for large configurations. Not used unless
	// the INT15, E820H call (Get System Address Map) failed.
	//
	// Input:
	//
	// AX   Function Code   E801h
	//
	// Outputs:
	//
	// CF   Carry Flag      Carry cleared indicates no error.
	// AX   Extended 1      Number of contiguous KB between 1 and 16 MB,
	//                      maximum 0x3C00 = 15 MB.
	// BX   Extended 2      Number of contiguous 64 KB blocks between
	//                      16 MB and 4 GB.
	// CX   Configured 1    Number of contiguous KB between 1 and 16 MB,
	//                      maximum 0x3C00 = 15 MB.
	// DX   Configured 2    Number of contiguous 64 KB blocks between
	//                      16 MB and 4 GB.

	bb.intno  = 0x15;
	bb.eax.rx = 0xe801;
	bios(&bb);

	// Return the size of memory above 1MB (extended memory) in kilobytes.

	if (bb.flags.cf == 0)
	{
		return (bb.ebx.rr * 64 + bb.eax.rr);
	}

	// Get Extended memory size. Called on last resort since the return
	// value is limited to 16-bits (a little less than 64MB max). May
	// not be supported by modern BIOSes.
	//
	// Input:
	//
	// AX   Function Code   88h
	//
	// Outputs:
	//
	// CF   Carry Flag      Carry cleared indicates no error.
	// AX   Memory Count    Number of contiguous KB above 1MB.

	bb.intno  = 0x15;
	bb.eax.rx = 0x88;
	bios(&bb);

	// Return the size of memory above 1MB (extended memory) in kilobytes.

	return bb.flags.cf ? 0 : bb.eax.rr;
}
示例#3
0
void video_mode(int mode)
{
	bb.intno = 0x10;
	bb.eax.r.h = 0x00;
	bb.eax.r.l = mode;
	bios(&bb);
}
int main(void) { //Main loop, runs once but can have an infinit loop in it
    cli();
    /*
    First we need to set the hardaware up, this is a macro in global.h which takes care of calling the various funtions that
    setup the registers to the proper seting, and also pulls the CPU_POW pin high
    if debug in GLOBAL.h is set, then debug keys will be sent out through the serial port
    when this function is called
    */
    bios();
    //if we're in debug mode, make sure you send stuff saying we got to the main code
    #if DEBUG
        uart_sendint(MAIN_KEY);
        #if DEBUG_BEG
            uart_sendstr("0x6 - Main code checkpoint...");
        #endif
    #endif

    sei();

    init_out('D', 5);
    //infinit loop that doesn't stop running. (always true since 1 is always 1 )
    while(1) {
        pwm1A(led);
    };
    return 0; //never reached since 1 is always true
}
示例#5
0
unsigned long getConventionalMemorySize()
{
	bb.intno = 0x12;
	bios(&bb);

	return bb.eax.rr;  // kilobytes
}
示例#6
0
void delay(int ms)
{
    bb.intno = 0x15;
    bb.eax.r.h = 0x86;
    bb.ecx.rr = ms >> 16;
    bb.edx.rr = ms & 0xFFFF;
    bios(&bb);
}
示例#7
0
文件: vbe.c 项目: Klozz/ChameleonFRK
int getVBECurrentMode(unsigned short *mode)
{
	bb.intno = 0x10;
	bb.eax.rr = funcGetCurrentMode;
	bios(&bb);
	*mode = bb.ebx.rr;
	return(bb.eax.r.h);
}
示例#8
0
文件: vbe.c 项目: Klozz/ChameleonFRK
int getVBEInfo( void *infoBlock )
{
    bb.intno  = 0x10;
    bb.eax.rr = funcGetControllerInfo;
    bb.es     = SEG( infoBlock );
    bb.edi.rr = OFF( infoBlock );
    bios( &bb );
    return(bb.eax.r.h);
}
示例#9
0
文件: vbe.c 项目: Klozz/ChameleonFRK
int getVBEDACFormat(unsigned char *format)
{
    bb.intno = 0x10;
    bb.eax.rr = funcGetSetPaletteFormat;
    bb.ebx.r.l = subfuncGet;
    bios(&bb);
    *format = bb.ebx.r.h;
    return(bb.eax.r.h);
}
示例#10
0
int fastEnableA20(void)
{
	bb.intno = 0x15;	
	bb.eax.rx = 0x2401;
	bios(&bb);

	// If successful: CF clear, AH = 00h. On error: CF set, AH = status
	return bb.flags.cf ? bb.eax.r.h : 0;
}
示例#11
0
void putca(int ch, int attr, int repeat)
{
	bb.intno   = 0x10;
	bb.ebx.r.h = 0x00;   /* page number */
	bb.ebx.r.l = attr;   /* attribute   */
	bb.eax.r.h = 0x9;
	bb.eax.r.l = ch;
	bb.ecx.rx  = repeat; /* repeat count */ 
	bios(&bb);
}
示例#12
0
文件: vbe.c 项目: Klozz/ChameleonFRK
int getVBEModeInfo( int mode, void *minfo_p )
{
    bb.intno  = 0x10;
    bb.eax.rr = funcGetModeInfo;
    bb.ecx.rr = mode;
    bb.es     = SEG(minfo_p);
    bb.edi.rr = OFF(minfo_p);
    bios(&bb);
    return(bb.eax.r.h);
}
示例#13
0
文件: vbe.c 项目: Klozz/ChameleonFRK
int getVBEPixelClock(unsigned short mode, unsigned long * pixelClock)
{
	bb.intno   = 0x10;
	bb.eax.rr  = funcGetSetPixelClock;
	bb.ebx.r.l = 0;
	bb.ecx.rx  = *pixelClock;
	bb.edx.rr  = mode;
	bios(&bb);
	*pixelClock = bb.ecx.rx;
	return(bb.eax.r.h);
}
示例#14
0
文件: vbe.c 项目: neilhart/RevoBoot
int getEDID(void * edidBlock, UInt8 block)
{
    bzero(&bb, sizeof(bb));
    bb.intno  = 0x10;
    bb.eax.rr = funcGetEDID;
    bb.ebx.r.l= 0x01;
    bb.edx.rr = block;
    bb.es     = SEG(edidBlock);
    bb.edi.rr = OFF(edidBlock);
    bios(&bb);
    return(bb.eax.r.h);
}
示例#15
0
文件: vbe.c 项目: Klozz/ChameleonFRK
int getVBEPalette(void *palette)
{
	bb.intno = 0x10;
	bb.eax.rr = funcGetSetPaletteData;
	bb.ebx.r.l = subfuncGet;
	bb.ecx.rr = 256;
	bb.edx.rr = 0;
	bb.es = SEG(palette);
	bb.edi.rr = OFF(palette);
	bios(&bb);
	return(bb.eax.r.h);
}
示例#16
0
int setVBEMode(unsigned short mode, const VBECRTCInfoBlock * timing)
{
    bb.intno  = 0x10;
    bb.eax.rr = funcSetMode;
    bb.ebx.rr = mode;
    if (timing) {
        bb.es     = SEG(timing);
        bb.edi.rr = OFF(timing);
    }
    bios(&bb);
    return(bb.eax.r.h);
}
示例#17
0
int is_no_emulation(int drive)
{
	struct packet
	{
		unsigned char packet_size;
		unsigned char media_type;
		unsigned char drive_num;
		unsigned char ctrlr_index;
		unsigned long lba;
		unsigned short device_spec;
		unsigned short buffer_segment;
		unsigned short load_segment;
		unsigned short sector_count;
		unsigned char cyl_count;
		unsigned char sec_count;
		unsigned char head_count;
		unsigned char reseved;
	} __attribute__((packed));
	static struct packet pkt;

	bzero(&pkt, sizeof(pkt));
	pkt.packet_size = 0x13;

	bb.intno   = 0x13;
	bb.eax.r.h = 0x4b;
	bb.eax.r.l = 0x01;     // subfunc: get info
	bb.edx.r.l = drive;
	bb.esi.rr = NORMALIZED_OFFSET((unsigned)&pkt);
	bb.ds     = NORMALIZED_SEGMENT((unsigned)&pkt);

	bios(&bb);

#if DEBUG
	printf("el_torito info drive %x\n", drive);
	printf("--> cf %x, eax %x\n", bb.flags.cf, bb.eax.rr);
	printf("pkt_size: %x\n", pkt.packet_size);
	printf("media_type: %x\n", pkt.media_type);
	printf("drive_num: %x\n", pkt.drive_num);
	printf("device_spec: %x\n", pkt.device_spec);
	printf("press a key->\n");
	getchar();
#endif

	/* Some BIOSes erroneously return cf = 1 */
	/* Just check to see if the drive number is the same. */
	if (pkt.drive_num == drive && (pkt.media_type & 0x0F) == 0)
	{
		return 1; // We are in no-emulation mode.
	}

	return 0;
}
示例#18
0
int readKeyboardStatus(void)
{
	bb.intno = 0x16;
	bb.eax.r.h = 0x01;
	bios(&bb);

	if (bb.flags.zf)
	{
		return 0;
	}

	return bb.eax.rr;
}
示例#19
0
int biosread(int dev, int cyl, int head, int sec, int num)
{
	int i;

	bb.intno = 0x13;
	sec += 1;  // sector numbers start at 1.
    
	for (i=0;;)
	{
		bb.ecx.r.h = cyl;
		bb.ecx.r.l = ((cyl & 0x300) >> 2) | (sec & 0x3F);
		bb.edx.r.h = head;
		bb.edx.r.l = dev;
		bb.eax.r.l = num;
		bb.ebx.rr  = OFFSET(ptov(BIOS_ADDR));
		bb.es      = SEGMENT(ptov(BIOS_ADDR));

		bb.eax.r.h = 0x02;
		bios(&bb);

		// In case of a successful call, make sure we set AH (return code) to zero.
		if (bb.flags.cf == 0)
		{
			bb.eax.r.h = 0;
		}

		// Now we can really check for the return code (AH) value.
		if ((bb.eax.r.h == 0x00) || (i++ >= 5))
		{
			break;
		}

        // Reset disk subsystem and try again.
		bb.eax.r.h = 0x00;
		bios(&bb);
	}

	return bb.eax.r.h;
}
示例#20
0
void TestDebugCPU::test()
{
    DebugCPU cpu;

    DebugMemory memory;
    IOPortList ioPortList(memory,cpu.getRegisterFile());
    Interrupt interrupt;

    cpu.initHardwareConnection(memory,ioPortList,interrupt);

    BIOS bios(memory,"bios.bin");
    cpu.start();
    cpu.wait();
}
示例#21
0
int bgetc(void)
{
    /*  Poll for the next character.  Most real BIOS do not need this as the
        INT 16h,AH=0h function will block until one is received.
        Unfortunately, Apple's EFI CSM will never wake up.  This idea is lifted
        from the grub-a20.patch to GRUB's stage2/asm.S file.
     */
	while(!readKeyboardStatus());

	bb.intno = 0x16;
	bb.eax.r.h = 0x00;
	bios(&bb);

	return bb.eax.rr;
}
示例#22
0
void p_s_top(void)
	{
	s_long=2;
	z_long=0;
	do
		{
		if(even(s_long))
			{
			print_at(s_long-1,72);
			printf(" %s ",z_char);
			}
		else
			{
			print_at(s_long,72);
			printf("%cp%s%cq",*chr(27),z_char,*chr(27));
			}
		pause( 10);
		if(gemdos(11) != 0)
			{
			z_long=gemdos(1);
			}
		if(z_long==0)
			{
			++s_long;
			z_long=d_iv(s_long,65);
			}
		else if(z_long==1)
			{
			--s_long;
			if(s_long==2)
				{
				z_long=0;
				}
			}
		pause( 10);
		if(bios(1,2) != 0)
			{
			z_long=inp(2);
			}
		}
	while(!(z_long>1));
	}
示例#23
0
unsigned int time18(void)
{
	union
	{
		struct
		{
			unsigned int low:16;
			unsigned int high:16;
		} s;

		unsigned int i;
	} time;
    
	bb.intno = 0x1a;
	bb.eax.r.h = 0x00;
	bios(&bb);
	time.s.low = bb.edx.rr;
	time.s.high = bb.ecx.rr;

	return time.i;
}
示例#24
0
short main(void)
{
	/* Check that MiNT is actually installed */
	/* Tried to use mintlibs Getcookie, but failed */
	if (Ssystem(-1, 0, 0) == 0)
	{
		N_AESINFO *cook;
		
		if (Ssystem(S_GETCOOKIE, 'nAES', 0) == -1)
		{
			cook = Mxalloc(sizeof(*cook), MX_GLOBAL | MX_PREFTTRAM);
			if (!cook)
				Cconws("Not enough memory\r\n");
			else
			{
				memset(cook, 0, sizeof(*cook));
				Ssystem(S_SETCOOKIE, 'nAES', (long)cook);	
				Cconws("\r\n\r\nXA_CHEAT: fake 'nAES' cookie.\r\n");
				Cconws("The use of this program is completely\r\n");
				Cconws("at your own risc.\r\n");
				Cconws("Any program accessing the pointer in this\r\n");
				Cconws("cookie will crash hopelessly.\r\n");
				Cconws("So do not use any N.Aes utilities!!!\r\n");
				Cconws("\r\n");
				Cconws("\r\n'nAES' cookie now faked.\r\n\r\n");
				Ptermres(2048, 0);
			}
		}
		else
			Cconws("nAES cookie already exists\r\n");
	}
	else
	{
		Cconws("XaCHEAT requires MiNT\r\n");
		bios(2,2);
	}
	return 0;
}
示例#25
0
文件: DISKTRAN.C 项目: k0gaMSX/legacy
main()
{
	char buffer[26*SECSIZ];	/* Track buffer */

	int toskew,fromskew;
	int track,sector;
	int index;

	char answer;

	puts("\t\tDISKTRAN\n\n");
	puts("A: Convert MCOS to CP/M\n\n");
	puts("B: Convert CP/M to MCOS\n");
	puts("\nEnter choice: ");
	while((answer=toupper(getchar()))!='A'&&answer!='B'){
		puts("\nPlease enter A or B\n");
		puts("Enter choice: ");
		}
	if(answer=='A'){
		toskew=CPM;
		fromskew=MCOS;
		}
	else{
		toskew=MCOS;
		fromskew=CPM;
		}

	puts("\n\nInsert source disk in drive A\n");
	puts("and destination disk in drive B, then hit a key\n");

	while(!kbhit());
		getchar();

	for(track=2;track<77;track++)
		{
		printf("Track %d\n",track);
		bios(SELECT_DISK,0);
		bios(SET_TRACK,track);
		sector=1;
		for(index=0;index<26;index++)
			{
			bios(SET_SECTOR,sector);
			bios(SET_DMA,&buffer[SECSIZ*index]);
			bios(READ_SECTOR);
			sector+=fromskew;
			if(sector>26)sector-=26;
			if(sector==1)sector=2;
			}
		bios(SELECT_DISK,1);
		sector=1;
		for(index=0;index<26;index++){
			bios(SET_SECTOR,sector);
			bios(SET_DMA,&buffer[SECSIZ*index]);
			bios(WRITE_SECTOR);
			sector+=toskew;
			if(sector>26)sector-=26;
			if(sector==1)sector=2;
			}
		}

	puts("Translation done\n");
	puts("Place system disk in drive A, and hit any key\n");
	while(!kbhit());
		getchar();
}
示例#26
0
int get_drive_info(int drive, struct driveInfo *dp)
{
    boot_drive_info_t *di = &dp->di;
    int ret = 0;

#if UNUSED
    if (maxhd == 0)
    {
        bb.intno = 0x13;
        bb.eax.r.h = 0x08;
        bb.edx.r.l = 0x80;
        bios(&bb);

        if (bb.flags.cf == 0)
            maxhd = 0x7f + bb.edx.r.l;
    };

    if (drive > maxhd)
        return 0;
#endif

    bzero(dp, sizeof(struct driveInfo));
    dp->biosdev = drive;

    /* Check for El Torito no-emulation mode. */
    dp->no_emulation = is_no_emulation(drive);

    /* Check drive for EBIOS support. */
    bb.intno = 0x13;
    bb.eax.r.h = 0x41;
    bb.edx.r.l = drive;
    bb.ebx.rr = 0x55aa;
    bios(&bb);

    if ((bb.ebx.rr == 0xaa55) && (bb.flags.cf == 0))
        dp->uses_ebios = bb.ecx.r.l; // Get flags for supported operations.

    if (dp->uses_ebios & (EBIOS_ENHANCED_DRIVE_INFO | EBIOS_LOCKING_ACCESS | EBIOS_FIXED_DISK_ACCESS))
    {
        // Get EBIOS drive info.
        static struct drive_params params;
        params.buf_size = sizeof(params);
        bb.intno = 0x13;
        bb.eax.r.h = 0x48;
        bb.edx.r.l = drive;
        bb.esi.rr = NORMALIZED_OFFSET((unsigned)&params);
        bb.ds     = NORMALIZED_SEGMENT((unsigned)&params);
        bios(&bb);

        if (bb.flags.cf != 0 /* || params.phys_sectors < 2097152 */)
        {
            dp->uses_ebios = 0;
            di->params.buf_size = 1;
        }
        else
        {
            bcopy(&params, &di->params, sizeof(params));

            if (drive >= BASE_HD_DRIVE && 
                (dp->uses_ebios & EBIOS_ENHANCED_DRIVE_INFO) &&
                di->params.buf_size >= 30 &&
                !(di->params.dpte_offset == 0xFFFF && di->params.dpte_segment == 0xFFFF))
            {
                void *ptr = (void *)(di->params.dpte_offset + ((unsigned int)di->params.dpte_segment << 4));
                bcopy(ptr, &di->dpte, sizeof(di->dpte));
            }
        }
    }

    if (dp->no_emulation)
    {
        /* Some BIOSes give us erroneous EBIOS support information.
         * Assume that if you're on a CD, then you can use
         * EBIOS disk calls.
         */
        dp->uses_ebios |= EBIOS_FIXED_DISK_ACCESS;
    }
#if DEBUG
    print_drive_info(di);
    printf("uses_ebios = 0x%x\n", dp->uses_ebios);
    printf("result %d\n", ret);
    printf("press a key->\n");getc();
#endif

    if (ret == 0)
        dp->valid = 1;

    return ret;
}
示例#27
0
int ebiosread(int dev, unsigned long long sec, int count)
{
	int i;
    
	static struct
	{
		unsigned char  size;
		unsigned char  reserved;
		unsigned char  numblocks;
		unsigned char  reserved2;
		unsigned short bufferOffset;
		unsigned short bufferSegment;
		unsigned long  long startblock;
	} addrpacket __attribute__((aligned(16))) = {0};
	addrpacket.size = sizeof(addrpacket);

	for (i = 0; ;)
	{
		bb.intno   = 0x13;
		bb.eax.r.h = 0x42;
		bb.edx.r.l = dev;
		bb.esi.rr  = NORMALIZED_OFFSET((unsigned)&addrpacket);
		bb.ds      = NORMALIZED_SEGMENT((unsigned)&addrpacket);
		addrpacket.reserved = addrpacket.reserved2 = 0;
		addrpacket.numblocks     = count;
		addrpacket.bufferOffset  = OFFSET(ptov(BIOS_ADDR));
		addrpacket.bufferSegment = SEGMENT(ptov(BIOS_ADDR));
		addrpacket.startblock    = sec;
		bios(&bb);

		// In case of a successful call, make sure we set AH (return code) to zero.
		if (bb.flags.cf == 0)
		{
			bb.eax.r.h = 0;
		}
		
		// Now we can really check for the return code (AH) value.
		if ((bb.eax.r.h == 0x00) || (i++ >= 5))
		{
			break;
		}

        // Reset disk subsystem and try again.
		bb.eax.r.h = 0x00;
		bios(&bb);
	}

	return bb.eax.r.h;
}


//==============================================================================

void putc(int ch)
{
	bb.intno = 0x10;
	bb.ebx.r.h = 0x00;  /* background black */
	bb.ebx.r.l = 0x0F;  /* foreground white */
	bb.eax.r.h = 0x0e;
	bb.eax.r.l = ch;
	bios(&bb);
}
示例#28
0
unsigned long getMemoryMap(MemoryRange * rangeArray, unsigned long maxRangeCount, unsigned long * conMemSizePtr, unsigned long * extMemSizePtr)
{
	#define kMemoryMapSignature  'SMAP'
	#define kDescriptorSizeMin   20

	MemoryRange *        range = (MemoryRange *)BIOS_ADDR;
	unsigned long        count = 0;
	unsigned long long   conMemSize = 0;
	unsigned long long   extMemSize = 0;

    // Prepare for the INT15 E820h call. Each call returns a single
    // memory range. A continuation value is returned that must be
    // provided on a subsequent call to fetch the next range.
    //
    // Certain BIOSes (Award 6.00PG) expect the upper word in EAX
    // to be cleared on entry, otherwise only a single range will
    // be reported.
    //
    // Some BIOSes will simply ignore the value of ECX on entry.
    // Probably best to keep its value at 20 to avoid surprises.

    //printf("Get memory map 0x%x, %d\n", rangeArray);getc();
    if (maxRangeCount > (BIOS_LEN / sizeof(MemoryRange)))
        maxRangeCount = (BIOS_LEN / sizeof(MemoryRange));

    bb.ebx.rx = 0;  // Initial continuation value must be zero.

    while (count < maxRangeCount)
    {
        bb.intno  = 0x15;
        bb.eax.rx = 0xe820;
        bb.ecx.rx = kDescriptorSizeMin;
        bb.edx.rx = kMemoryMapSignature;
        bb.edi.rr = NORMALIZED_OFFSET(  (unsigned long) range );
        bb.es     = NORMALIZED_SEGMENT( (unsigned long) range );
        bios(&bb);

        // Check for errors.

        if ( bb.flags.cf ||   bb.eax.rx != kMemoryMapSignature
            || bb.ecx.rx != kDescriptorSizeMin )
        {
            //printf("Got an error %x %x %x\n", bb.flags.cf,
            //       bb.eax.rx, bb.ecx.rx);
            break;
        }

        // Tally up the conventional/extended memory sizes.

        if (range->type == kMemoryRangeUsable || range->type == kMemoryRangeACPI   ||
            range->type == kMemoryRangeNVS )
        {
            // Tally the conventional memory ranges.
            if (range->base + range->length <= 0xa0000)
                conMemSize += range->length;

            // Record the top of extended memory.
            if (range->base >= EXTENDED_ADDR)
                extMemSize += range->length;
        }

        range++;
        count++;

        // Is this the last address range?

        if ( bb.ebx.rx == 0 ) {
            //printf("last range\n");
            break;
        }
    }
    *conMemSizePtr = conMemSize / 1024;  // size in KB
    *extMemSizePtr = extMemSize / 1024;  // size in KB

    // Copy out data
    bcopy((char *)BIOS_ADDR, rangeArray, ((char *)range - (char *)BIOS_ADDR));

#if DEBUG
    {
        int i;
        printf("%d total ranges\n", count);getc();

        for (i=0, range = rangeArray; i<count; i++, range++)
        {
            printf("range: type %d, base 0x%x, length 0x%x\n",
                   range->type, (unsigned int)range->base, (unsigned int)range->length);
            getc();
        }
    }
#endif

    return count;
}