Clubcos  0.0.0
Clubcos - Clubc Operating System
 모두 데이타 구조 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 매크로 페이지들
memory.h
이 파일의 문서화 페이지로 가기
1 
2 // Copyright (c) 2014, 임경현 (dlarudgus20)
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice, this
9 // list of conditions and the following disclaimer.
10 //
11 // * Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
34 #ifndef MEMORY_H_
35 #define MEMORY_H_
36 
37 #include <stddef.h>
38 #include <stdint.h>
39 #include <stdbool.h>
40 #include "memory_map.h"
41 
43 #define DYN_MEM_BUDDY_UNIT_SIZE (4 * 1024u)
44 
46 typedef struct tagBuddyBitmap
47 {
48  uint8_t *bits;
49  uint32_t count;
50 } BuddyBitmap;
51 
53 typedef struct tagDynMemStruct
54 {
55  uint32_t DynMemSize;
56 
57  uint32_t BeginAddr;
58  uint32_t UsedSize;
59 
60  uint32_t CountOfUnitBlock;
61  uint32_t BitmapLevel;
62 
64 } DynMemStruct;
65 
67 extern DynMemStruct g_DynMem;
68 
72 void ckDynMemInitialize(void);
77 void *ckDynMemAllocate(uint32_t size);
83 bool ckDynMemFree(void *addr, uint32_t size);
84 
89 uint32_t ckDynMemCheckSize(void);
94 static inline uint32_t ckDynMemGetSize(void)
95 {
96  return g_DynMem.DynMemSize;
97 }
98 
104 static inline bool ckDynMemPhyIsDynMem(uint32_t phy)
105 {
106  return (DYN_MEMORY_PHYSICAL_ADDRESS < phy && phy < 0xc0000000);
107 }
113 static inline bool ckDynMemLocIsDynMem(uint32_t loc)
114 {
116 }
117 
118 #endif /* MEMORY_H_ */
struct tagDynMemStruct DynMemStruct
동적 메모리를 관리하는 구조체입니다.
동적 메모리를 관리하는 구조체입니다.
Definition: memory.h:53
BuddyBitmap * arBitmap
buddy block을 저장하는 비트맵들을 가리키는 포인터입니다.
Definition: memory.h:63
uint32_t CountOfUnitBlock
최소 크기(DYN_MEM_BUDDY_UNIT_SIZE )의 buddy block의 갯수입니다.
Definition: memory.h:60
uint32_t count
비트맵에서 1로 설정된 비트의 갯수입니다.
Definition: memory.h:49
uint8_t * bits
비트맵의 포인터입니다.
Definition: memory.h:48
uint32_t UsedSize
메타데이터를 제외한, 현재 할당되어 사용되고 있는 동적 메모리 영역의 크기입니다.
Definition: memory.h:58
uint32_t BeginAddr
buddy block 메타데이터를 제외한 동적 메모리 영역의 시작 주소입니다.
Definition: memory.h:57
#define DYN_MEMORY_START_ADDRESS
동적 메모리 영역의 선형 시작 주소입니다.
Definition: memory_map.h:77
uint32_t ckDynMemCheckSize(void)
돟적 메모리의 크기를 검사하고 g_Dynmem.DynMemSize에 저장합니다.
Definition: memory.c:266
void ckDynMemInitialize(void)
buddy block 알고리즘을 사용하는 동적 메모리 관리자를 초기화합니다.
Definition: memory.c:71
uint32_t DynMemSize
동적 메모리 영역의 크기입니다.
Definition: memory.h:55
struct tagBuddyBitmap BuddyBitmap
동적 메모리를 관리하는 buddy block을 기록하는 비트맵 자료구조입니다.
#define DYN_MEMORY_PHYSICAL_ADDRESS
동적 메모리 영역의 물리 시작 주소입니다.
Definition: memory_map.h:85
void * ckDynMemAllocate(uint32_t size)
동적 메모리에서 메모리를 할당받습니다.
Definition: memory.c:122
동적 메모리를 관리하는 buddy block을 기록하는 비트맵 자료구조입니다.
Definition: memory.h:46
#define IOMAP_MEMORY_START_ADDRESS
I/O 맵핑 메모리 영역의 선형 시작 주소입니다.
Definition: memory_map.h:79
bool ckDynMemFree(void *addr, uint32_t size)
동적 메모리에서 할당한 메모리를 해제합니다.
Definition: memory.c:179
DynMemStruct g_DynMem
DynMemStruct 입니다.
Definition: memory.c:38
uint32_t BitmapLevel
buddy block 계층의 갯수입니다.
Definition: memory.h:61