mirror of
https://github.com/limine-bootloader/limine
synced 2025-03-04 17:01:39 +03:00
Fix conv_mem_alloc bug introduced by e721c3c
This commit is contained in:
parent
11240b59a5
commit
0dc73b3529
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
@ -220,11 +220,11 @@ next:
|
||||
|
||||
int r = strcmp(token, name);
|
||||
|
||||
conv_mem_rewind();
|
||||
conv_mem_rewind(dir->name_len + 1);
|
||||
|
||||
if (!r) {
|
||||
if (escape) {
|
||||
conv_mem_rewind();
|
||||
conv_mem_rewind(sizeof(struct ext2_inode));
|
||||
return 0;
|
||||
} else {
|
||||
// update the current inode
|
||||
@ -236,7 +236,7 @@ next:
|
||||
i += dir->rec_len;
|
||||
}
|
||||
|
||||
conv_mem_rewind();
|
||||
conv_mem_rewind(sizeof(struct ext2_inode));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -264,9 +264,8 @@ extern symbol bss_end;
|
||||
static size_t bump_allocator_base = (size_t)bss_end;
|
||||
static size_t bump_allocator_limit = 0;
|
||||
|
||||
void conv_mem_rewind(void) {
|
||||
size_t *old_base = (size_t *)(bump_allocator_base - sizeof(size_t));
|
||||
bump_allocator_base = *old_base;
|
||||
void conv_mem_rewind(size_t count) {
|
||||
bump_allocator_base -= count;
|
||||
}
|
||||
|
||||
void *conv_mem_alloc(size_t count) {
|
||||
@ -286,14 +285,9 @@ void *conv_mem_alloc_aligned(size_t count, size_t alignment) {
|
||||
|
||||
size_t new_base = ALIGN_UP(bump_allocator_base, alignment);
|
||||
void *ret = (void *)new_base;
|
||||
|
||||
size_t *old_base = (size_t *)(new_base + count);
|
||||
new_base += count + sizeof(size_t);
|
||||
|
||||
new_base += count;
|
||||
if (new_base >= bump_allocator_limit)
|
||||
panic("Memory allocation failed");
|
||||
|
||||
*old_base = bump_allocator_base;
|
||||
bump_allocator_base = new_base;
|
||||
|
||||
// Zero out allocated space
|
||||
|
@ -22,7 +22,7 @@ void *ext_mem_alloc_type(size_t count, uint32_t type);
|
||||
void *ext_mem_alloc_aligned(size_t count, size_t alignment);
|
||||
void *ext_mem_alloc_aligned_type(size_t count, size_t alignment, uint32_t type);
|
||||
|
||||
void conv_mem_rewind(void);
|
||||
void conv_mem_rewind(size_t count);
|
||||
void *conv_mem_alloc(size_t count);
|
||||
void *conv_mem_alloc_aligned(size_t count, size_t alignment);
|
||||
|
||||
|
@ -126,7 +126,7 @@ struct smp_information *init_smp(size_t *cpu_count,
|
||||
if (!smp_start_ap(lapic->lapic_id, &gdtr, info_struct,
|
||||
longmode, lv5, (uint32_t)pagemap.top_level)) {
|
||||
print("smp: FAILED to bring-up AP\n");
|
||||
conv_mem_rewind();
|
||||
conv_mem_rewind(sizeof(struct smp_information));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user