⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memory.c

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 C
字号:
/* *  Broadcom Cryptonet Driver software is distributed as is, without any warranty *  of any kind, either express or implied as further specified in the GNU Public *  License. This software may be used and distributed according to the terms of *  the GNU Public License. * * Cryptonet is a registered trademark of Broadcom Corporation. *//* *  Copyright 2000 *  Broadcom Corporation *  16215 Alton Parkway *  PO Box 57013 *  Irvine CA 92619-7013 * *****************************************************************************//* * Broadcom Corporation uBSec SDK *//* * Revision History: * * March 2001 PW Created, Release for Linux 2.4 UP and SMP kernel */                                         #include "cdevincl.h"#ifndef LINUX2dot2struct pci_dev *globalpDev;#endif void *LinuxAllocateMemory(unsigned long size) ;void LinuxFreeMemory(void *virtual);#if 0void *LinuxAllocateMemory(unsigned long size) {    dma_addr_t dma_handle;    struct list_node *temp;    void *virtual;        temp = my_get_free_q();    if (temp == NULL) {        printk("<0> Unable to allocate memory\n");        while(1);    }    virtual = pci_alloc_consistent(globalpDev, size, &dma_handle);    my_put_busy_q(temp, virtual, size, dma_handle);    return virtual;}voidLinuxFreeMemory(void *virtual){    struct list_node *temp;    struct pci_dev *pDev;    if ((temp = my_get_busy_q(virtual)) == NULL) {        printk("<0> Unable to find virtual %x\n",virtual);        return;    }    pci_free_consistent(globalpDev, temp->size, virtual, temp->dma_handle);    my_put_free_q(temp);    }#elsevoid *LinuxAllocateMemory(unsigned long size){   return kmalloc(size, GFP_KERNEL|GFP_ATOMIC);}voidLinuxFreeMemory(void *virtual){    kfree(virtual);}void *LinuxAllocateDMAMemory(unsigned long size) {    return kmalloc(size, GFP_KERNEL| GFP_ATOMIC);}voidLinuxFreeDMAMemory(void *virtual){    kfree(virtual);}#endifunsigned longLinuxGetPhysicalAddress(void *virtual){   return virt_to_bus(virtual);}unsigned longLinuxGetVirtualAddress(void *virtual){   return (unsigned long) virtual ;}void *LinuxMapPhysToIO(unsigned long Physical_Address, int size){	return ioremap(Physical_Address,size );}void LinuxUnMapIO( unsigned long ioaddr){	iounmap((void *)ioaddr);}/* Made the access functions generic as viewed by SRL(OS_AllocateDMA ... */void * Linux_AllocateDMAMemory(ubsec_DeviceContext_t * context, int size){	return LinuxAllocateMemory(size);}void  Linux_FreeDMAMemory(void * virtual , int size){	LinuxFreeMemory(virtual);	return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -