Check-in [c00b7817c2]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:refactored paging_init.cpp
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1:c00b7817c2406f53f87c1d881e49dc4a14e6b7cf
User & Date: maxi 2018-12-14 16:18:21
Context
2018-12-14
16:18
refactored paging_init.cpp Leaf check-in: c00b7817c2 user: maxi tags: trunk
2018-11-13
06:38
Added trunk's greeter check-in: 113d0291b5 user: maxi tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/memory/paging_init.cpp.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29
30
31
32
33
34
35
36
37
38
39
40
41

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
uint64_t physical_memory;
} // namespace Physical

page_directory *page_dir;

const uint32_t mem_beg = 0x01000000 + (1 << 12) + (4 << 20);
uint32_t block_count = 0;

inline void handle_usable_memory_block(auto &memory_block)
{
	if (memory_block.base_addr_low % (4 << 10))
	{
		memory_block.length_low -= (memory_block.base_addr_low % (4 << 10));
		memory_block.base_addr_low = memory_block.base_addr_low -
							   (memory_block.base_addr_low % (4 << 10)) + (4 << 10);
	}
	auto before_last_b = memory_block.base_addr_low + memory_block.length_low - (1 << 16);
	if (memory_block.base_addr_low >= mem_beg)
	{

		for (auto it = memory_block.base_addr_low; it <= before_last_b; it += 1 << 16)
		{
			Physical::memory->add_block((char *)it);
			++block_count;
		}
	}
	else if (memory_block.base_addr_low + memory_block.length_low >= mem_beg)
	{
          for (auto it = mem_beg; it <= before_last_b; it += 1 << 16) {
            Physical::memory->add_block((char *)it);
            ++block_count;
		}
	}

}

uint64_t initialize(multiboot_memory_map_t *mmap, size_t len)
{
	multiboot_memory_map32_t *map = (multiboot_memory_map32_t *)mmap;
	Physical::memory = new ((void *)0x01000000)
		Physical::physical_layout((char *)(0x01000000 + (1 << 12)), 4 << 20);
	for (uint32_t i = 0; i < len; i++)
		if (map[i].type == 1)
			handle_usable_memory_block(map[i]);

	Physical::physical_memory = block_count << 16;

	page_dir = new (Physical::memory->malloc(sizeof(page_dir))) page_directory();

	return Physical::physical_memory;
}
} // namespace Paging






|
|
|




|


<
|
>
|
<
<
<
<
<
<
<
|
|
<
|
<
>









|








10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

27
28
29







30
31

32

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
uint64_t physical_memory;
} // namespace Physical

page_directory *page_dir;

const uint32_t mem_beg = 0x01000000 + (1 << 12) + (4 << 20);
uint32_t block_count = 0;
inline void append_block(auto &memory_block)
{
	// Align to x86 block boundaries
	if (memory_block.base_addr_low % (4 << 10))
	{
		memory_block.length_low -= (memory_block.base_addr_low % (4 << 10));
		memory_block.base_addr_low = memory_block.base_addr_low -
									 (memory_block.base_addr_low % (4 << 10)) + (4 << 10);
	}
	auto before_last_b = memory_block.base_addr_low + memory_block.length_low - (1 << 16);


	// Split the memory block
	auto it_start = memory_block.base_addr_low >= mem_beg ? memory_block.base_addr_low : mem_beg;







	for (auto it = it_start; it <= before_last_b; it += 1 << 16)
		Physical::memory->add_block(reinterpret_cast<char *>(it));



	block_count += (before_last_b - it_start) / (1 << 16);
}

uint64_t initialize(multiboot_memory_map_t *mmap, size_t len)
{
	multiboot_memory_map32_t *map = (multiboot_memory_map32_t *)mmap;
	Physical::memory = new ((void *)0x01000000)
		Physical::physical_layout((char *)(0x01000000 + (1 << 12)), 4 << 20);
	for (uint32_t i = 0; i < len; i++)
		if (map[i].type == 1)
			append_block(map[i]);

	Physical::physical_memory = block_count << 16;

	page_dir = new (Physical::memory->malloc(sizeof(page_dir))) page_directory();

	return Physical::physical_memory;
}
} // namespace Paging