rev 0.1快乐虾http://blog.csdn.net/lights_joy/lights@hb165.com本文适用于ADI bf561 DSP优视BF561EVB开发板uclinux-2008r1.5-rc3 (smp patch)Visual DSP++ 5.0(update 5)欢迎转载,但请保留作者信息这是uclinux最先处理的几个内核参数之一,对它的处理由parse_cmdline_early函数完成,在此函数的注释中,简单说明了此参数的作用及其格式:*- Controlling the linux memory size: mem=xxx[KMG]即它将用来控制内核可管理的内存大小,此大小可能比整个物理内存小,比如在典型的bf561的双核应用中,一般的uclinux使用A核及一半的SDRAM,另一半交由B核程序管理,此时就必须使用mem参数。看看检测到mem参数时的处理代码片段:……………if (!memcmp(to, "mem=", 4)) {to += 4;memsize = memparse(to, &to);if (memsize)_ramend = memsize;} elseif (!memcmp(to, "max_mem=", 8)) {………….在这里,memparse只是简单地分析字符串后的数字,并返回一个整数,如果用户输入的参数不符合指定格式,此函数将返回0:/***memparse - parse a string with mem suffixes into a number*@ptr: Where parse begins*@retptr: (output) Pointer to next char after parse completes**Parses a string into a number.The number stored at @ptr is*potentially suffixed with %K (for kilobytes, or 1024 bytes),*%M (for megabytes, or 1048576 bytes), or %G (for gigabytes, or*1073741824).If the number is suffixed with K, M, or G, then*the return value is the number multiplied by one kilobyte, one*megabyte, or one gigabyte, respectively.*/unsignedlonglong memparse (char *ptr, char **retptr){unsignedlonglong ret = simple_strtoull (ptr, retptr, 0);switch (**retptr) {case'G':case'g':ret <<= 10;case'M':case'm':ret <<= 10;case'K':case'k':ret <<= 10;(*retptr)++;default:break;}return ret;}在得到正确的数字后,简单地将此数字赋给_ramend这一全局变量。_ramend用于指向内核可管理的内存的最后一个字节,在默认情况下,它将指向可用内存的末尾。