remove obsolete function arguments

This commit is contained in:
Stefan Lankes 2011-02-24 10:15:58 +01:00
parent c5b650fc32
commit 16efb49204
7 changed files with 42 additions and 46 deletions

View file

@ -77,23 +77,23 @@ typedef struct page_dir
/*
* Converts a virtual address to a physical
*/
size_t virt_to_phys(task_t*, size_t);
size_t virt_to_phys(size_t);
/*
* Allocates an virtual address space range of npages
*/
size_t vm_alloc(task_t* task, uint32_t npages, uint32_t flags);
size_t vm_alloc(uint32_t npages, uint32_t flags);
/*
* Frees a range in the virtual address space
*/
int vm_free(task_t* task, size_t addr, uint32_t npages);
int vm_free(size_t addr, uint32_t npages);
/*
* Maps a physical memory region at a specific virtual address.
* If the virtual address is zero, this functions allocates a valid virtual address on demand.
*/
size_t map_region(task_t* task, size_t viraddr, size_t phyaddr, uint32_t pages, uint32_t type);
size_t map_region(size_t viraddr, size_t phyaddr, uint32_t pages, uint32_t type);
/*
* Sets up the environment and enables paging.

View file

@ -211,7 +211,7 @@ int smp_init(void)
* they jump to smp_main.
*/
bootaddr = 0x10000;
map_region(per_core(current_task), bootaddr, get_pages(1), 1, MAP_KERNEL_SPACE);
map_region(bootaddr, get_pages(1), 1, MAP_KERNEL_SPACE);
for(i=0; i<sizeof(boot_code); i+=sizeof(size_t))
{
// replace 0xDEADC0DE with the address of the smp entry code
@ -249,12 +249,12 @@ int apic_calibration(void)
if (!has_apic())
return -ENXIO;
lapic = map_region(per_core(current_task), 0 /*lapic*/, lapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
lapic = map_region(0 /*lapic*/, lapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
if (BUILTIN_EXPECT(!lapic, 0))
return -ENXIO;
if (ioapic)
ioapic = map_region(per_core(current_task), 0 /*(size_t)ioapic*/, (size_t)ioapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
ioapic = map_region(0 /*(size_t)ioapic*/, (size_t)ioapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
old = get_clock_tick();
@ -291,12 +291,12 @@ int apic_calibration(void)
if (!has_apic())
return -ENXIO;
lapic = map_region(per_core(current_task), 0 /*lapic*/, lapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
lapic = map_region(0 /*lapic*/, lapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
if (BUILTIN_EXPECT(!lapic, 0))
return -ENXIO;
if (ioapic)
ioapic = map_region(per_core(current_task), 0 /*(size_t)ioapic*/, (size_t)ioapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
ioapic = map_region(0 /*(size_t)ioapic*/, (size_t)ioapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
lapic_write(APIC_DCR, 0xB); // set it to 1 clock increments
lapic_write(APIC_LVT_T, 0x2007B); // connects the timer to 123 and enables it

View file

@ -76,7 +76,7 @@ int create_default_frame(task_t* task, entry_point_t ep, void* arg)
task_state_segments[id].gs = ds;
task_state_segments[id].es = ds;
task_state_segments[id].eflags = 0x1202;
task_state_segments[id].cr3 = (uint32_t) (virt_to_phys(per_core(current_task), (size_t)task->pgd));
task_state_segments[id].cr3 = (uint32_t) (virt_to_phys((size_t)task->pgd));
task_state_segments[id].eip = (uint32_t) ep;
task_state_segments[id].esp = (uint32_t) kstacks[id] + KERNEL_STACK_SIZE - sizeof(size_t);

View file

@ -107,8 +107,8 @@ int get_user_pgd(task_t* task)
index2 = (viraddr >> 12) & 0x3FF;
// now, we create a self reference
pgd->entries[index1] = ((size_t) virt_to_phys(per_core(current_task), (size_t) pgt) & 0xFFFFF000)|KERN_TABLE;
pgt->entries[index2] = ((size_t) virt_to_phys(per_core(current_task), (size_t) pgt) & 0xFFFFF000)|KERN_PAGE;
pgd->entries[index1] = ((size_t) virt_to_phys((size_t) pgt) & 0xFFFFF000)|KERN_TABLE;
pgt->entries[index2] = ((size_t) virt_to_phys((size_t) pgt) & 0xFFFFF000)|KERN_PAGE;
task->pgd = pgd;
task->pgd_lock = &boot_pgd_lock;
@ -116,8 +116,9 @@ int get_user_pgd(task_t* task)
return 0;
}
size_t virt_to_phys(task_t* task, size_t viraddr)
size_t virt_to_phys(size_t viraddr)
{
task_t* task = per_core(current_task);
uint32_t index1, index2;
page_table_t* pgt;
size_t ret = 0;
@ -146,8 +147,9 @@ out:
return ret;
}
size_t map_region(task_t* task, size_t viraddr, size_t phyaddr, uint32_t npages, uint32_t flags)
size_t map_region(size_t viraddr, size_t phyaddr, uint32_t npages, uint32_t flags)
{
task_t* task = per_core(current_task);
page_table_t* pgt;
size_t index, i;
size_t ret;
@ -159,7 +161,7 @@ size_t map_region(task_t* task, size_t viraddr, size_t phyaddr, uint32_t npages,
return 0;
if (!viraddr) {
viraddr = vm_alloc(task, npages, flags);
viraddr = vm_alloc(npages, flags);
if (BUILTIN_EXPECT(!viraddr, 0)) {
kputs("map_adress: found no valid virtual address\n");
return 0;
@ -290,8 +292,9 @@ int change_page_permissions(size_t start, size_t end, uint32_t flags)
*
* TODO: O(n) => bad performance, we need a better approach
*/
size_t vm_alloc(task_t* task, uint32_t npages, uint32_t flags)
size_t vm_alloc(uint32_t npages, uint32_t flags)
{
task_t* task = per_core(current_task);
uint32_t index1, index2, j;
size_t viraddr, i;
size_t start, end;
@ -335,8 +338,9 @@ size_t vm_alloc(task_t* task, uint32_t npages, uint32_t flags)
return 0;
}
int vm_free(task_t* task, size_t viraddr, uint32_t npages)
int vm_free(size_t viraddr, uint32_t npages)
{
task_t* task = per_core(current_task);
uint32_t i;
uint32_t index1, index2;
page_table_t* pgt;
@ -435,11 +439,11 @@ int arch_paging_init(void)
npages = ((size_t) &kernel_end - (size_t) &kernel_start) / PAGE_SIZE;
if ((size_t)&kernel_end % PAGE_SIZE)
npages++;
map_region(per_core(current_task), (size_t)&kernel_start, (size_t)&kernel_start, npages, MAP_KERNEL_SPACE);
map_region((size_t)&kernel_start, (size_t)&kernel_start, npages, MAP_KERNEL_SPACE);
#ifdef CONFIG_VGA
// map the video memory into the kernel space
map_region(per_core(current_task), VIDEO_MEM_ADDR, VIDEO_MEM_ADDR, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
map_region(VIDEO_MEM_ADDR, VIDEO_MEM_ADDR, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
#endif
#ifdef CONFIG_MULTIBOOT
@ -447,7 +451,7 @@ int arch_paging_init(void)
* of course, mb_info has to map into the kernel space
*/
if (mb_info)
map_region(per_core(current_task), (size_t) mb_info, (size_t) mb_info, 1, MAP_KERNEL_SPACE);
map_region((size_t) mb_info, (size_t) mb_info, 1, MAP_KERNEL_SPACE);
/*
* Map reserved memory regions into the kernel space
@ -461,7 +465,7 @@ int arch_paging_init(void)
npages = mmap->len / PAGE_SIZE;
if ((mmap->addr+mmap->len) % PAGE_SIZE)
npages++;
map_region(per_core(current_task), mmap->addr, mmap->addr, npages, MAP_KERNEL_SPACE|MAP_NO_CACHE);
map_region(mmap->addr, mmap->addr, npages, MAP_KERNEL_SPACE|MAP_NO_CACHE);
}
mmap++;
}
@ -479,7 +483,7 @@ int arch_paging_init(void)
npages = (mmodule->mod_end - mmodule->mod_start) / PAGE_SIZE;
if (mmodule->mod_end % PAGE_SIZE)
npages++;
map_region(per_core(current_task), (size_t) (mmodule->mod_start), (size_t) (mmodule->mod_start), npages, MAP_KERNEL_SPACE);
map_region((size_t) (mmodule->mod_start), (size_t) (mmodule->mod_start), npages, MAP_KERNEL_SPACE);
}
}
#endif

View file

@ -315,7 +315,7 @@ err_t rtl8139if_init(struct netif* netif)
uint16_t tmp16, speed;
uint8_t tmp8;
static uint8_t num = 0;
task_t* task = per_core(current_task);
//task_t* task = per_core(current_task);
LWIP_ASSERT("netif != NULL", (netif != NULL));
@ -434,13 +434,13 @@ err_t rtl8139if_init(struct netif* netif)
outportl(rtl8139if->iobase + TCR, TCR_IFG|TCR_MXDMA0|TCR_MXDMA1|TCR_MXDMA2);
// register the receive buffer
outportl(rtl8139if->iobase + RBSTART, virt_to_phys(task, (size_t) rtl8139if->rx_buffer));
outportl(rtl8139if->iobase + RBSTART, virt_to_phys((size_t) rtl8139if->rx_buffer));
// set each of the transmitter start address descriptors
outportl(rtl8139if->iobase + TSAD0, virt_to_phys(task, (size_t) rtl8139if->tx_buffer[0]));
outportl(rtl8139if->iobase + TSAD1, virt_to_phys(task, (size_t) rtl8139if->tx_buffer[1]));
outportl(rtl8139if->iobase + TSAD2, virt_to_phys(task, (size_t) rtl8139if->tx_buffer[2]));
outportl(rtl8139if->iobase + TSAD3, virt_to_phys(task, (size_t) rtl8139if->tx_buffer[3]));
outportl(rtl8139if->iobase + TSAD0, virt_to_phys((size_t) rtl8139if->tx_buffer[0]));
outportl(rtl8139if->iobase + TSAD1, virt_to_phys((size_t) rtl8139if->tx_buffer[1]));
outportl(rtl8139if->iobase + TSAD2, virt_to_phys((size_t) rtl8139if->tx_buffer[2]));
outportl(rtl8139if->iobase + TSAD3, virt_to_phys((size_t) rtl8139if->tx_buffer[3]));
/*
* To set the RTL8139 to accept only the Transmit OK (TOK) and Receive OK (ROK)

View file

@ -225,7 +225,7 @@ static int STDCALL user_entry(void* arg)
flags |= MAP_CODE;
// map page frames in the address space of the current task
if (!map_region(per_core(current_task), prog_header.virt_addr, addr, npages, flags))
if (!map_region(prog_header.virt_addr, addr, npages, flags))
kprintf("Could not map 0x%x at 0x%x\n", addr, prog_header.virt_addr);
// clear pages
@ -256,7 +256,7 @@ static int STDCALL user_entry(void* arg)
addr = get_pages(npages);
stack = header.entry*2; // virtual address of the stack
if (!map_region(per_core(current_task), stack, addr, npages, MAP_USER_SPACE)) {
if (!map_region(stack, addr, npages, MAP_USER_SPACE)) {
kprintf("Could not map stack at 0x%x\n", stack);
return -ENOMEM;
}

View file

@ -176,8 +176,9 @@ int mmu_init(void)
/*
* Use first fit algorithm to find a suitable physical memory region
*/
static size_t task_get_pages(task_t* task, uint32_t npages)
size_t get_pages(uint32_t npages)
{
task_t* task = per_core(current_task);
uint32_t i, j, l;
uint32_t k = 0;
size_t ret = 0;
@ -234,11 +235,6 @@ oom:
return ret;
}
size_t get_pages(uint32_t npages)
{
return task_get_pages(per_core(current_task), npages);
}
void* mem_allocation(size_t sz, uint32_t flags)
{
size_t phyaddr, viraddr;
@ -248,12 +244,12 @@ void* mem_allocation(size_t sz, uint32_t flags)
if (sz % PAGE_SIZE)
npages++;
phyaddr = task_get_pages(task, npages);
phyaddr = get_pages(npages);
if (BUILTIN_EXPECT(!phyaddr, 0))
return 0;
spinlock_lock(task->pgd_lock);
viraddr = map_region(task, 0, phyaddr, npages, flags);
viraddr = map_region(0, phyaddr, npages, flags);
spinlock_unlock(task->pgd_lock);
return (void*) viraddr;
@ -264,8 +260,9 @@ void* kmalloc(size_t sz)
return mem_allocation(sz, MAP_KERNEL_SPACE|MAP_HEAP);
}
static void task_free(task_t* task, void* addr, size_t sz)
void kfree(void* addr, size_t sz)
{
task_t* task = per_core(current_task);
uint32_t index, npages, i;
size_t phyaddr;
@ -279,7 +276,7 @@ static void task_free(task_t* task, void* addr, size_t sz)
spinlock_lock(&bitmap_lock);
for(i=0; i<npages; i++) {
phyaddr = virt_to_phys(task, (size_t) addr+i*PAGE_SIZE);
phyaddr = virt_to_phys((size_t) addr+i*PAGE_SIZE);
if (!phyaddr)
continue;
@ -290,15 +287,10 @@ static void task_free(task_t* task, void* addr, size_t sz)
spinlock_unlock(&bitmap_lock);
spinlock_lock(task->pgd_lock);
vm_free(task, (size_t) addr, npages);
vm_free((size_t) addr, npages);
spinlock_unlock(task->pgd_lock);
atomic_int32_sub(&total_allocated_pages, npages);
atomic_int32_add(&total_available_pages, npages);
atomic_int32_sub(&(task->mem_usage), npages);
}
void kfree(void* addr, size_t sz)
{
task_free(per_core(current_task), addr, sz);
}