Example #1
0
ACPI_STATUS
AcpiOsWriteMemory (
    ACPI_PHYSICAL_ADDRESS   Address,
    UINT64                  Value,
    UINT32                  Width)
{
	unsigned long *la = toLogicalAddress((unsigned long)Address);
	switch (Width) {
	case 8:
		*((uint8_t*)la) = (uint8_t)Value;
		break;
	case 16:
		*((uint16_t*)la) = (uint16_t)Value;
		break;
	case 32:
		*((uint32_t*)la) = (uint32_t)Value;
		break;
	case 64:
		*((uint64_t*)la) = (uint64_t)Value;
		break;
	default:
		return (AE_BAD_PARAMETER);
	}
	return (AE_OK);
}
Example #2
0
/*
 * Memory map
 *	When paddr is NULL, allocate len bytes of memory having contiguous physical address,
 *	and returns the logical address to *laddr.
 *	When paddr is not NULL, map len bytes of physical memory from paddr and returns 
 *	the logical address to *laddr.
 *
 *	N.B. Access to *laddr may cause page fault.
 */
LOCAL ER _MapMemory( CONST void *paddr, INT len, UINT attr, void **laddr )
{
	ER	ercd;
	UINT	a;

	if ( len <= 0 ) {
		ercd = E_PAR;
		goto err_ret;
	}

	a = ( (attr & MM_USER) != 0 )? TA_RNG3: TA_RNG0;
	if ( (attr & MM_CDIS) != 0 ) {
		a |= TA_NOCACHE;
	}

	if ( paddr == NULL ) {
		/* Allocate memory automatically */
		*laddr = GetSysMemBlk((INT)smPageCount((UW)len), a);
		if ( *laddr == NULL ) {
			ercd = E_NOMEM;
			goto err_ret;
		}

		/* Set memory access privilege */
		ercd = _SetMemoryAccess(*laddr, len, (attr & (MM_READ|MM_WRITE|MM_EXECUTE)));
		if ( ercd < E_OK ) {
			RelSysMemBlk(*laddr);
			*laddr = NULL;
			goto err_ret;
		}

	} else {
		/* Logical address conversion */
		*laddr = toLogicalAddress(paddr);

		/* Flush cache */
		FlushCache(*laddr, len);

		if ( (attr & MM_CDIS) != 0 ) {
			/* Allocate logical addresses for cache off area */
			*laddr = toNoCacheLogicalAddress(*laddr);
		}
	}

	return E_OK;

err_ret:
#ifdef DEBUG
	TM_DEBUG_PRINT(("_MapMemory ercd = %d\n", ercd));
#endif
	return ercd;
}
Example #3
0
void *
AcpiOsMapMemory (
    ACPI_PHYSICAL_ADDRESS   where,
    ACPI_SIZE               length)
{
	struct page *page;
	unsigned long la;
	
	page = map_paddr_pages(where, length);
	
	if (!page) {
		return(NULL);
	}
	
	la = toLogicalAddress(where);
	
	return((void*)la);
//    return (ACPI_TO_POINTER ((ACPI_SIZE) where));
}
Example #4
0
/*
 * Memory map
 *	Cache control required, but cache control by page cannot be
 *	provided without MMU (except for certain machines), so not implemented.
 */
LOCAL ER _MapMemory( VP paddr, INT len, UINT attr, VP *laddr )
{
	ER	ercd;

	if ( len <= 0 ) {
		ercd = E_PAR;
		goto err_ret;
	}

	if ( paddr == NULL ) {
		UINT a = ( (attr & MM_USER) != 0 )? TA_RNG3: TA_RNGS;
		if ( (attr & MM_CDIS) != 0 ) {
			a |= TA_NOCACHE;
		}

		/* Allocate memory automatically */
		*laddr = GetSysMemBlk((INT)smPageCount((UW)len), a);
		if ( *laddr == NULL ) {
			ercd = E_NOMEM;
			goto err_ret;
		}

	} else {
		/* Logical address conversion */
		*laddr = toLogicalAddress(paddr);

		/* Flush cache */
		FlushCache(*laddr, len);

		if ( (attr & MM_CDIS) != 0 ) {
			/* Allocate logical addresses for cache off area */
			*laddr = toNoCacheLogicalAddress(*laddr);
		}
	}

	return E_OK;

err_ret:
	DEBUG_PRINT(("_MapMemory ercd = %d\n", ercd));
	return ercd;
}