예제 #1
0
파일: uart.cpp 프로젝트: KevinOConnor/haret
void UART_pxa_setup()
{
  UINT32 *base=(UINT32*)VirtualAlloc((void*)0x0,sizeof(void*)*0xffff, MEM_RESERVE,PAGE_READWRITE);
  VirtualCopy(base,(void *) ((FUART)/256),sizeof(void*)*0xffff	, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);

  // set DLAB
  base[0x0C/4]=128+2+1;
  // set divisor
  base[0]=8; // 115200 bps
  base[0x04/4]=0;
  // unset DLAB
  base[0x0C/4]=2+1;
  // UART enable & no FIFO
  base[0x04/4]=64;
  base[0x08/4]=0;

  char test[]="LinExec: UART Initialized.\n\r";
  int a=0;
  while(test[a])
  {
    while(!(base[0x14/4]&1<<5)) {}
    base[0]=(char)(test[a]);
    a++;
  }
}
예제 #2
0
// Miscellaneous internal routines.
PUCHAR
static
CCSer_InternalMapRegisterAddresses(
    ULONG   HWAddress,
    ULONG   Size
    )
{
	PUCHAR	ioPortBase; 

    DEBUGMSG(ZONE_FUNCTION, 
             (TEXT("+CCSer_InternalMapRegisterAddresses: adr=0x%x len=0x%x\r\n"),
			 HWAddress, Size));

	ioPortBase = VirtualAlloc(0, Size, MEM_RESERVE, PAGE_NOACCESS);
	if ( ioPortBase == NULL )
	{
		ERRORMSG(1, (TEXT("CCSer_InternalMapRegisterAddresses: VirtualAlloc failed!\r\n")));
	}
	else if ( !VirtualCopy((PVOID)ioPortBase, (PVOID)HWAddress, Size, PAGE_READWRITE|PAGE_NOCACHE) )
	{
		ERRORMSG(1, (TEXT("CCSer_InternalMapRegisterAddresses: VirtualCopy failed!\r\n")));
		VirtualFree( (PVOID)ioPortBase, 0, MEM_RELEASE );
		ioPortBase = 0;
	}

    DEBUGMSG(ZONE_FUNCTION, 
             (TEXT("-CCSer_InternalMapRegisterAddresses: mapped at 0x%x\r\n"),
              ioPortBase ));

    return ioPortBase;
}
예제 #3
0
파일: uart.cpp 프로젝트: KevinOConnor/haret
void UART_pxa_puts(char *s)
{
  UINT32 *base=(UINT32*)VirtualAlloc((void*)0x0,sizeof(void*)*0xffff, MEM_RESERVE,PAGE_READWRITE);
  VirtualCopy(base,(void *) ((FUART)/256),sizeof(void*)*0xffff	, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);
  int a=0;
  while(s[a])
  {
    while(!(base[0x14/4]&1<<5)) {}
    base[0]=(char)(s[a]);
    a++;
  }
}
예제 #4
0
void *
KdMapDevice (CARD32 addr, CARD32 size)
{
#ifdef WINDOWS
    void    *a;
    void    *d;

    d = VirtualAlloc (NULL, size, MEM_RESERVE, PAGE_NOACCESS);
    if (!d)
	return NULL;
    DRAW_DEBUG ((DEBUG_S3INIT, "Virtual address of 0x%x is 0x%x", addr, d));
    a = VirtualCopyAddr (addr);
    DRAW_DEBUG ((DEBUG_S3INIT, "Translated address is 0x%x", a));
    if (!VirtualCopy (d, a, size, 
		      PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL))
    {
	DRAW_DEBUG ((DEBUG_FAILURE, "VirtualCopy failed %d",
		    GetLastError ()));
	return NULL;
    }
    DRAW_DEBUG ((DEBUG_S3INIT, "Device mapped successfully"));
    return d;
#endif
#ifdef linux
    void    *a;
    int	    fd;

#ifdef __arm__
    fd = open ("/dev/mem", O_RDWR|O_SYNC);
#else
    fd = open ("/dev/mem", O_RDWR);
#endif
    if (fd < 0)
	FatalError ("KdMapDevice: failed to open /dev/mem (%s)\n",
		    strerror (errno));
    
    a = mmap ((caddr_t) 0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, addr);
    close (fd);
    if ((long) a == -1)
	FatalError ("KdMapDevice: failed to map frame buffer (%s)\n",
		    strerror (errno));
    return a;
#endif
#ifdef VXWORKS
    return (void *) addr;
#endif
}
예제 #5
0
PVOID NIC_DRIVER_OBJECT::DriverBindAddress(
	U32		uPhysicalAddress,
	U32		uLength)
{
	void	*pvoid;
	// allocate memory for the work space
	
    if(!(pvoid = VirtualAlloc(
		NULL, 
		uLength,
		MEM_RESERVE, 
		PAGE_NOACCESS))) return NULL;

	/* binding this virtual addr to physical location */
	VirtualCopy(
		pvoid,
		(PVOID)uPhysicalAddress,
		uLength,
		PAGE_READWRITE | PAGE_NOCACHE);

	return pvoid;
}
예제 #6
0
파일: giz.c 프로젝트: 133794m3r/picodrive
static void *mmap_phys(unsigned int addr, int pages)
{
	void *mem;
	int ret;

	mem = VirtualAlloc(0, pages*PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS);
	if (mem == NULL)
	{
		lprintf("VirtualAlloc failed\n");
		return NULL;
	}

	ret = VirtualCopy(mem, (void *)addr, pages*PAGE_SIZE, PAGE_READWRITE | PAGE_NOCACHE);
	if (ret == 0)
	{
		lprintf("VirtualFree failed\n");
		VirtualFree(mem, 0, MEM_RELEASE);
		return NULL;
	}

	return mem;
}
예제 #7
0
/*****************************************************************************
*   FUNCTION :  	GetVirtualAddressOfUncachedMemory
*   DESCRIPTION :   Associates virtual addr with physical memory region
*   INPUTS :		Physical adddress of memory region (page aligned)
*					Size of region to be reserved
*					String identifying point of invocation (for error msgs)
*   OUTPUTS :     	Virtual address associated (or NULL, if failure occurs)
*   DESIGN NOTES :  
*   CAUTIONS :
*****************************************************************************/
extern "C"  PBYTE GetVirtualAddressOfUncachedMemory(
	PBYTE physicalAddress,
	DWORD size,
	char* callerID)
{
	PBYTE virtualAddress;

#define here "GetVirtualAddressOfUncachedMemory"

	FUNC(here);
	if ((ULONG)physicalAddress % PAGE_SIZE) 
	{
		ERRMSG2((TEXT(here "%s: Physical Addr (0x%x) Not Page-Aligned\r\n")), callerID, physicalAddress);
	}
	
	virtualAddress = (PBYTE)VirtualAlloc(
		NULL,
		size,
		MEM_RESERVE,
		PAGE_NOACCESS);
	
	if (virtualAddress == NULL) 
	{
		ERRMSG1((TEXT(here "%s: Virtual Alloc Failed\r\n")), callerID);
		return NULL;
	}
	
	if (!VirtualCopy((PVOID) virtualAddress,
		(PVOID) physicalAddress,
		size,
		PAGE_READWRITE | PAGE_NOCACHE))
	{
		ERRMSG1((TEXT(here "%s: Virtual Copy Failed\r\n")), callerID);
		FreeAllocatedVirtualMemory( virtualAddress );
		return NULL;
	}
	return virtualAddress;
}