source: UsbWattMeter/trunk/asp_dcre/library/mem_pool.c@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 797 bytes
Line 
1/*
2 * ‘æ3‰ñ TOPPERSŠˆ—pƒAƒCƒfƒAEƒAƒvƒŠƒP[ƒVƒ‡ƒ“ŠJ”­ƒRƒ“ƒeƒXƒg
3 * ¼‰Y Œõ—m‚³‚ñ‚́ulwIP ‚̈ڐAv‚ðƒx[ƒX‚É‚µ‚Ü‚µ‚½B
4 * http://www.toppers.jp/contest.html
5 *
6 * @(#) $Id: mem_pool.c 164 2016-03-07 11:33:50Z coas-nagasima $
7 */
8//asp\doc\porting.txt
9//6.15.1‚æ‚è
10
11#include "kernel/kernel_impl.h"
12#include "tlsf.h"
13
14static tlsf_t tlsf_kmm;
15static pool_t pool_kmm;
16
17void
18initialize_kmm(void)
19{
20 if ((kmm == NULL) || (kmmsz <= tlsf_size())) {
21 tlsf_kmm = NULL;
22 return;
23 }
24
25 tlsf_kmm = tlsf_create(kmm);
26 if (tlsf_kmm == NULL)
27 return;
28
29 pool_kmm = tlsf_add_pool(tlsf_kmm, ((uint8_t *)kmm) + tlsf_size(), kmmsz - tlsf_size());
30}
31
32void *
33kernel_malloc(SIZE size)
34{
35 if (tlsf_kmm != NULL) {
36 return tlsf_malloc(tlsf_kmm, size);
37 }
38 else {
39 return(NULL);
40 }
41}
42
43void
44kernel_free(void *ptr)
45{
46 if (tlsf_kmm != NULL) {
47 tlsf_free(tlsf_kmm, ptr);
48 }
49}
Note: See TracBrowser for help on using the repository browser.