mm: refactor pmm -> page

This commit is contained in:
Matheus
2026-07-01 11:56:06 -03:00
parent 39e63c3e44
commit 6f8700e678
35 changed files with 226 additions and 226 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
#include <kernel/virtio.h>
#include <logging.h>
#include <kernel/pmm.h>
#include <kernel/page.h>
#include <kernel/eth.h>
#include <kernel/net.h>
#include <hashtable.h>
+6 -6
View File
@@ -4,7 +4,7 @@
#include <arch/io.h>
#include <kernel/net.h>
#include <kernel/scheduler.h>
#include <kernel/pmm.h>
#include <kernel/page.h>
#include <kernel/eth.h>
#include <kernel/interrupt.h>
@@ -198,7 +198,7 @@ static int rtl8169_sendpacket(netdev_t *internal, netdesc_t desc, mac_t target,
static int rtl8169_allocdesc(netdev_t *netdev, size_t requested_size, netdesc_t *desc) {
__assert(requested_size <= netdev->mtu);
size_t true_size = sizeof(ethframe_t) + requested_size;
void *physical = pmm_allocpage(PMM_SECTION_DEFAULT);
void *physical = mm_alloc_page(MEMORY_SECTION_DEFAULT);
if (physical == NULL)
return ENOMEM;
@@ -209,7 +209,7 @@ static int rtl8169_allocdesc(netdev_t *netdev, size_t requested_size, netdesc_t
}
static int rtl8169_freedesc(netdev_t *netdev, netdesc_t *desc) {
pmm_release(FROM_HHDM(desc->address));
mm_release_page(FROM_HHDM(desc->address));
return 0;
}
@@ -275,9 +275,9 @@ static void init_controller(pcienum_t *pci_enum) {
printf("rtl8169.%d: %x:%x:%x:%x:%x:%x\n", id, mac.address[0], mac.address[1], mac.address[2], mac.address[3], mac.address[4], mac.address[5]);
// set up descriptor rings
descriptor_t *tx_ring_phys = pmm_alloc(ROUND_UP(sizeof(descriptor_t) * TX_DESCRIPTOR_COUNT, PAGE_SIZE) / PAGE_SIZE, PMM_SECTION_DEFAULT);
descriptor_t *tx_ring_phys = mm_alloc_pages(ROUND_UP(sizeof(descriptor_t) * TX_DESCRIPTOR_COUNT, PAGE_SIZE) / PAGE_SIZE, MEMORY_SECTION_DEFAULT);
__assert(tx_ring_phys);
descriptor_t *rx_ring_phys = pmm_alloc(ROUND_UP(sizeof(descriptor_t) * RX_DESCRIPTOR_COUNT, PAGE_SIZE) / PAGE_SIZE, PMM_SECTION_DEFAULT);
descriptor_t *rx_ring_phys = mm_alloc_pages(ROUND_UP(sizeof(descriptor_t) * RX_DESCRIPTOR_COUNT, PAGE_SIZE) / PAGE_SIZE, MEMORY_SECTION_DEFAULT);
__assert(rx_ring_phys);
descriptor_t *tx_ring = MAKE_HHDM(tx_ring_phys);
@@ -288,7 +288,7 @@ static void init_controller(pcienum_t *pci_enum) {
// fill rx descriptors
// XXX figure out a better way of doing this
void *rx_buffer = pmm_alloc(ROUND_UP((RX_DESCRIPTOR_COUNT * RX_BUFFER_SIZE), PAGE_SIZE) / PAGE_SIZE, PMM_SECTION_DEFAULT);
void *rx_buffer = mm_alloc_pages(ROUND_UP((RX_DESCRIPTOR_COUNT * RX_BUFFER_SIZE), PAGE_SIZE) / PAGE_SIZE, MEMORY_SECTION_DEFAULT);
__assert(rx_buffer);
for (int i = 0; i < RX_DESCRIPTOR_COUNT; ++i) {
+1 -1
View File
@@ -285,7 +285,7 @@ static int udp_recv(socket_t *socket, sockdesc_t *sockdesc) {
__assert(sockdesc->donecount == copycount);
// remove the message if not asked to peek
// remove the message if not asked to peek TODO: if sonecount != header.length, add truncate flag. also do the same to localsocket
if ((flags & SOCKET_RECV_FLAGS_PEEK) == 0)
ringbuffer_truncate(&udpsocket->ringbuffer, sizeof(header) + header.length);
+4 -4
View File
@@ -1,6 +1,6 @@
#include <kernel/virtio.h>
#include <logging.h>
#include <kernel/pmm.h>
#include <kernel/page.h>
#include <kernel/eth.h>
#include <kernel/net.h>
#include <hashtable.h>
@@ -84,7 +84,7 @@ static void tx_irq(isr_t *isr, context_t *context) {
static int vionet_allocdesc(netdev_t *netdev, size_t requestedsize, netdesc_t *desc) {
__assert(requestedsize <= netdev->mtu);
size_t truesize = PREFIX_SIZE + requestedsize;
void *phys = pmm_allocpage(PMM_SECTION_DEFAULT);
void *phys = mm_alloc_page(MEMORY_SECTION_DEFAULT);
if (phys == NULL)
return ENOMEM;
@@ -95,7 +95,7 @@ static int vionet_allocdesc(netdev_t *netdev, size_t requestedsize, netdesc_t *d
}
static int vionet_freedesc(netdev_t *netdev, netdesc_t *desc) {
pmm_release(FROM_HHDM(desc->address));
mm_release_page(FROM_HHDM(desc->address));
return 0;
}
@@ -210,7 +210,7 @@ int vionet_newdevice(viodevice_t *viodevice) {
// XXX is the memory saving of allocating hundreds of KiBs of contiguous physical memory really worth it?
// the system literally might not have enough (contiguous) physical memory for this, especially considering
// this device is initialised deeper into the boot process.
void *receivebuffer = pmm_alloc(ROUND_UP((rxsize * BUFFER_SIZE), PAGE_SIZE) / PAGE_SIZE, PMM_SECTION_DEFAULT);
void *receivebuffer = mm_alloc_pages(ROUND_UP((rxsize * BUFFER_SIZE), PAGE_SIZE) / PAGE_SIZE, MEMORY_SECTION_DEFAULT);
__assert(receivebuffer);
for (int i = 0; i < rxsize; ++i) {