ADS中堆地址的设置方法
来源:互联网 发布:2016最新淘宝刷单技巧 编辑:程序博客网 时间:2024/06/06 00:04
在使用ADS编译器进行ARM开发时,如果程序需要一块内存,在不上OS的情况下,一般调用malloc()函数。然而在调用之前必须保证你已经为程序分配了堆内存。有的汇编引导代码替你完成了这一步,比如本人以前用过的ZLG系列的工程模板,有的需要自己设定堆内存。
查看ADS的inline books有如下描述:
Using a heap implementation from bare machine C
To use a heap implementation in an application that does not define main() and does not
initialize the C library:
1. Call _init_alloc(base, top) to define the base and top of the memory you want
to manage as a heap.
2. Define the function unsigned __rt_heap_extend(unsigned size, void ** block)
to handle calls to extend the heap when it becomes full.
以上说明如果入口函数为标准的C库入口_main函数,则_main函数会帮助我们初始化堆的基地址,比如ZLG的模板。很多时候我们会自定义入口函数_Main,这种情况下就需要我们自己定义堆的基地址,注意堆的地址范围不要和复制的向量中断表的地址空间冲突。
从online books中看到要定义堆空间,要调用_init_alloc(base,top)函数。_rt_heap_extend()用来扩展堆空间。其他堆操作函数可以在ADS的online books中找到。注意在调用这些函数是要包含头文件#inciude <rt_heap.h>。
附本人在44b0中应用的一段代码:
#include <stdlib.h>
#include <rt_heap.h>
#include "44B.h"
#include "def.h"
#include "Option.h"
#include "44blib.h"
#define SIZE 3072
U8 *pblock=NULL;
void Main(void)
{
_init_alloc(0xc7fe000, 0xc7ff000); //申请4K空间的对内存,0xc7ff000为中断向量表起始地址
pblock=(U8*)malloc(SIZE);
/*memory use*/
free(pblock);
pblock=NULL;
}
本文转载自博客ID坠落尘埃
- ADS中堆地址的设置方法
- ADS中堆地址的设置方法
- ADS的基本设置
- ADS的基本设置
- ADS中对于C库的初始化设置
- ads调试工程的设置
- redhat中设置ip地址的几种方法
- Centos中设置静态IP地址的方法
- ADS 设置
- 程序代码中 变量的地址 ,逻辑地址,栈,堆 等等
- ADS中自定义verilogA模型添加方法
- Linux虚拟机中设置DNS地址方法
- ADS里的字体支持中文设置
- ads优化设置中优化方式random和gradient的选择
- Eclipse中堆内存的设置
- Eclipse中堆内存的设置
- arm中ads实现c和汇编混合编译的方法
- Linux 设置永久ip地址的方法
- wince5+2440的睡眠和唤醒——转载
- malloc/free 和 new /delete 的区别
- mysql 多字段 联合唯一
- strust1.x 上传图片
- pthread多线程编程整理
- ADS中堆地址的设置方法
- javascript 正则表达式
- VC6安装错误——Error Launching acmboot.exe
- 为什么要设置 jdk 的 path?
- char,wchar_t,WCHAR,TCHAR,ACHAR的区别
- php5中php.ini 设置教程中文版
- FCKeditor 使用体会
- SQL查询条件优化
- 让Delphi的DataSnap发挥最大效率