예제 #1
0
파일: at250xx.cpp 프로젝트: bieli/avr_jokes
int At250xx::Verify(int type)
{
    if (GetNoOfBank() == 0)
        return BADPARAM;

    int size = GetNoOfBank() * GetBankSize();
    unsigned char *localbuf;
    localbuf = new unsigned char[size];
    if (localbuf == 0)
        return OUTOFMEMORY;

    int rval = 1;
    if (type & PROG_TYPE)
    {
        rval = GetBus()->Read(0, localbuf, size);
        if (rval != size)
        {
            if (rval > 0)
                rval = OP_ABORTED;
        }
        else
        {
            rval = ( memcmp(GetBufPtr(), localbuf, size) != 0 ) ? 0 : 1;
        }
    }
    delete localbuf;

    return rval;
}
예제 #2
0
파일: at250xx.cpp 프로젝트: bieli/avr_jokes
int At250xx::Read(int probe, int type)
{
    UserDebug1(UserApp1, "At250xx::Read(%d)\n", probe);

    if (probe || GetNoOfBank() == 0)
        Probe();

    int size = GetNoOfBank() * GetBankSize();

    UserDebug1(UserApp1, "At250xx::Read() ** Size = %d\n", size);

    int rv = size;
    if (type & PROG_TYPE)
    {
        rv = GetBus()->Read(0, GetBufPtr(), size);
        if (rv != size)
        {
            if (rv > 0)
                rv = OP_ABORTED;
        }
    }

    UserDebug1(UserApp1, "At250xx::Read() = %d\n", rv);

    return rv;
}
예제 #3
0
파일: at250xx.cpp 프로젝트: bieli/avr_jokes
int At250xx::Write(int probe, int type)
{
    if (probe || GetNoOfBank() == 0)
        Probe();

    int size = GetNoOfBank() * GetBankSize();

    int rv = size;
    if (type & PROG_TYPE)
    {
        rv = GetBus()->Write(0, GetBufPtr(), size);
        if (rv != size)
        {
            if (rv > 0)
                rv = OP_ABORTED;
        }
    }

    return rv;
}
예제 #4
0
파일: fpmem.c 프로젝트: dduval/kernel-rhel3
int
build_efi_memmap(void *md, int mdsize)
{
	int		numnodes = GetNumNodes() ;
	int		cnode,bank ;
	int		nasid ;
	node_memmap_t	membank_info ;
	int		bsize;
	int		count = 0 ;
	long		paddr, hole, numbytes;


	for (cnode=0;cnode<numnodes;cnode++) {
		nasid = GetNasid(cnode) ;
		membank_info = GetMemBankInfo(cnode) ;
		for (bank=0;bank<PLAT_CLUMPS_PER_NODE;bank++) {
			if (IsBankPresent(bank, membank_info)) {
				bsize = GetBankSize(bank, membank_info) ;
                                paddr = PHYS_ADDRESS(nasid, (long)bank<<MD_BANK_SHFT);
                                numbytes = BankSizeBytes(bsize);
#ifdef CONFIG_IA64_SGI_SN2
				/* 
				 * Ignore directory.
				 * Shorten memory chunk by 1 page - makes a better
				 * testcase & is more like the real PROM.
				 */
				numbytes = numbytes * 31 / 32;
#endif
				/*
				 * Only emulate the memory prom grabs
				 * if we have lots of memory, to allow
				 * us to simulate smaller memory configs than
				 * we can actually run on h/w.  Otherwise,
				 * linux throws away a whole "granule".
				 */
				if (cnode == 0 && bank == 0 &&
				    numbytes > 128*1024*1024) {
					numbytes -= 1000;
				}

                                /*
                                 * Check for the node 0 hole. Since banks cant
                                 * span the hole, we only need to check if the end of
                                 * the range is the end of the hole.
                                 */
                                if (paddr+numbytes == NODE0_HOLE_END)
                                        numbytes -= NODE0_HOLE_SIZE;
                                /*
                                 * UGLY hack - we must skip overr the kernel and
                                 * PROM runtime services but we dont exactly where it is.
                                 * So lets just reserve:
				 *	node 0
				 *		0-1MB for PAL
				 *		1-4MB for SAL
				 *	node 1-N
				 *		0-1 for SAL
                                 */
                                if (bank == 0) {
					if (cnode == 0) {
						hole = 1*1024*1024;
						build_mem_desc(md, EFI_PAL_CODE, paddr, hole);
						numbytes -= hole;
                                        	paddr += hole;
			        		count++ ;
                                        	md += mdsize;
						hole = 3*1024*1024;
						build_mem_desc(md, EFI_RUNTIME_SERVICES_DATA, paddr, hole);
						numbytes -= hole;
                                        	paddr += hole;
			        		count++ ;
                                        	md += mdsize;
					} else {
						hole = PROMRESERVED_SIZE;
                                        	build_mem_desc(md, EFI_RUNTIME_SERVICES_DATA, paddr, hole);
						numbytes -= hole;
                                        	paddr += hole;
			        		count++ ;
                                        	md += mdsize;
					}
                                }
                                build_mem_desc(md, EFI_CONVENTIONAL_MEMORY, paddr, numbytes);

			        md += mdsize ;
			        count++ ;
			}
		}
	}
	return count ;
}