计算机处理外部信息的工作原理

计算机处理外部信息的工作原理,第1张

如果只是无法进中断,你检查下NVIC的中断映射是否配置,我用的是DMA发送,给你参考下。

相关定义:

#define USART1_Tx_DMA_Channel    DMA1_Channel4

#define USART1_Tx_DMA_STREAM     DMA2_Stream7

#define USART1_Tx_DMA_TCIF       DMA1_FLAG_TC4

#define USART1_Rx_DMA_Channel    DMA1_Channel5

#define USART1_Rx_DMA_FLAG       DMA1_FLAG_TC5 

#define USART1_DR_Base           ((uint32_t)&USART1->DR)

代码:

#ifdef USART1_USE_DMA_MODE

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); //使能DMA1时钟

#ifdef USART1_DMA_TX

    NVIC_InitStructureNVIC_IRQChannel = DMA1_Channel4_IRQn; //设置中断通道

    NVIC_InitStructureNVIC_IRQChannelPreemptionPriority = 0; //主优先级设置

    NVIC_InitStructureNVIC_IRQChannelSubPriority = 0;         //设置优先级

    NVIC_InitStructureNVIC_IRQChannelCmd = ENABLE; //打开中断

    NVIC_Init(&NVIC_InitStructure); 

    DMA_DeInit(USART1_Tx_DMA_Channel);  

    DMA_InitStructureDMA_PeripheralBaseAddr = USART1_DR_Base;

    DMA_InitStructureDMA_MemoryBaseAddr = (uint32_t)m_UartDCBpSendBuff;

    DMA_InitStructureDMA_DIR = DMA_DIR_PeripheralDST;

    DMA_InitStructureDMA_PeripheralInc = DMA_PeripheralInc_Disable;

    DMA_InitStructureDMA_MemoryInc = DMA_MemoryInc_Enable;

    DMA_InitStructureDMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;

    DMA_InitStructureDMA_MemoryDataSize = DMA_MemoryDataSize_Byte;

    DMA_InitStructureDMA_Mode = DMA_Mode_Normal;

    DMA_InitStructureDMA_Priority = DMA_Priority_VeryHigh;

    DMA_InitStructureDMA_M2M = DMA_M2M_Disable;

    DMA_Init(USART1_Tx_DMA_Channel, &DMA_InitStructure); //配置DMA1

    DMA_ITConfig(USART1_Tx_DMA_Channel, DMA_IT_TC, ENABLE);    //使能DMA发送中断

#endif //_USART_DMA_TX__

#endif //USE_DMA_MODE

what is ION

ION  内存管理从android40开始被引入

ION模块是可扩展的(API都是统一的),支持各种形式的内存分配方式,可以表述不同的硬件资源和他们的一些限制

ION 支持连续与不连续内存的分配

ION 给Kernel and User space processes提供了相应的APIs

当前支持的memory type

ION_HEAP_TYPE_CARVEOUT - memory (PMEM style) for larger physically contiguous allocations

ION_HEAP_TYPE_SYSTEM_CONTIG - physically contiguous for small physical allocations

ION_HEAP_TYPE_SYSTEM - virtually contiguous but physically discontiguous memory

ION_HEAP_TYPE_IOMMU - memory region allocated through IOMMU API

ION heap 的大小根据每个设备自身的内存情况而定,但是都要实现下面的回调:

   struct ion_heap_ops {

        int (allocate) (struct ion_heap heap,

                       struct ion_buffer buffer, unsigned long len,

                       unsigned long align, unsigned long flags);

        void (free) (struct ion_buffer buffer);

        int (phys) (struct ion_heap heap, struct ion_buffer buffer,

               ion_phys_addr_t addr, size_t len);

        struct scatterlist (map_dma) (struct ion_heap heap,

                       struct ion_buffer buffer);

        void (unmap_dma) (struct ion_heap heap,

        struct ion_buffer buffer);

        void (map_kernel) (struct ion_heap heap,

        struct ion_buffer buffer);

        void (unmap_kernel) (struct ion_heap heap,

        struct ion_buffer buffer);

        int (map_user) (struct ion_heap heap, struct ion_buffer buffer,

                       struct vm_area_struct vma);

   };

方法phys(),返回的是的物理地址和buffer的长度,但必须是连续的物理buffer,如果没有连续的物理buffer,是不能提供改回调。

map_kernel() and unmap_kernel(),把物理内存映射到kernel virtual address space

map_user(),映射物理内存到用户空间,为啥没有unmap_user()方法呢,因为映射到用户空间,是以FD(文件描述符)的形式映射的,当FD close了就自动unmap。

ION可以释放内存嘛?

答案是否定的。它主要的是提供给applications间共享内存。

ION和PMem可以共存嘛?

可以,但是不能共享buffers

userspace是如何使用ION?

1:open ION device-------open("/dev/ion", O_RDONLY),返回一个FD(相当于ION client)

2:  客户端要填充如下数据结构,除了handle,也就是你要申请的data:

struct ion_allocation_data {

        size_t len;

        size_t align;

        unsigned int flags;

        struct ion_handle handle;

   }

3: user space clients 用ioctl跟ION通信

int ioctl(int client_fd, ION_IOC_ALLOC, struct ion_allocation_data allocation_data)

返回的FD的buffer。

4:FD可以通过Binder机制进行进程间的share

如何查看ION的使用量

for example:

>adb shell

 #mount -t debugfs NONE /d

 #cd /d/ion/

 #ls

 922

 vmalloc

 

 # cat vmalloc

 cat vmalloc

 client pid size

 total bytes currently allocated: 0

 # cat 922

 cat 922

 heap_name: size_in_bytes : handle refcount : buffer

 client refcount: 1

ION 和DMABUF的比较:

Feature ION DMABUF

Memory Manager RoleION replaces PMEM as the manager of provisioned memory pools The list of ION heaps can be extended per deviceDMABUF is a buffer sharing framework, designed to integrate with the memory allocators in DMA mapping frameworks, like the work-in-progress DMA-contiguous allocator, also known as the Contiguous Memory Allocator  (CMA) DMABUF exporters have the option to implement custom allocators

User Space Access ControlION offers the /dev/ion interface for user-space programs to allocate and share buffers Any user program with ION access can cripple the system by depleting the ION heaps Android checks user and group IDs to block unauthorized access to ION heapsDMABUF offers only kernel APIs Access control is a function of the permissions on the devices using the DMABUF feature

Global Client and Buffer DatabaseION contains a device driver associated with /dev/ion The device structure contains a database that tracks the allocated ION buffers, handles and file descriptors, all grouped by user clients and kernel clients ION validates all client calls according to the rules of the database For example, there is a rule that a client cannot have two handles to the same bufferThe  DMA debug facility  implements a global hashtable,dma_entry_hash, to track DMA buffers, but only when the kernel was built with theCONFIG_DMA_API_DEBUG option

Cross-architecture UsageION usage today is limited to architectures that run the Android kernelDMABUF usage is cross-architecture The  DMA mapping redesign preparation patchset  modified the DMA mapping code in 9 architectures besides the ARM architecture

Buffer SynchronizationION considers buffer synchronization to be an orthogonal problemDMABUF provides a pair of APIs for synchronization The buffer-user callsdma_buf_map_attachment()whenever it wants to use the buffer for DMA Once the DMA for the current buffer-user is over, it signals 'end-of-DMA' to the exporter via a call todma_buf_unmap_attachment()

Delayed Buffer AllocationION allocates the physical memory before the buffer is sharedDMABUF can defer the allocation until the first call todma_buf_map_attachment() The exporter of DMA buffer has the opportunity to scan all client attachments, collate their buffer constraints, then choose the appropriate backing storage

计算机的基本原理是存贮程序和程序控制。预先要把指挥计算机如何进行 *** 作的指令序列(称为程序)和原始数据通过输入设备输送到计算机内存贮器中。每一条指令中明确规定了计算机从哪个地址取数,进行什么 *** 作,然后送到什么地址去等步骤。

扩展资料

组成部分

软件系统

软件系统包括: *** 作系统、应用软件等。应用软件中电脑行业的管理软件,IT电脑行业的发展必备利器,电脑行业的erp软件。

硬件系统

硬件系统包括:机箱(电源、硬盘、磁盘、 内存、主板、CPU-中央处理器、CPU风扇、光驱、声卡、网卡、显卡)、显示器、UPS(不间断电源供应系统)、键盘、鼠标等等(另可配有耳机、麦克风、音箱、打印机、摄像头等)。家用电脑一般主板都有板载声卡、网卡。部分主板装有集成显卡。

以上就是关于STM32 DMA无法进入中断全部的内容,包括:STM32 DMA无法进入中断、ION 内存管理、计算机处理外部信息的工作原理等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/8809765.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-21
下一篇 2023-04-21

发表评论

登录后才能评论

评论列表(0条)

保存