lib/aos/paging.c
errval_t paging_alloc(struct paging_state *st, void **buf, size_t bytes)
{
    struct paging_frame_node *node = &st->free_node;
    while(node != NULL) {
        if(node->size >= bytes) {
            *buf = (void*)node->base_addr;
 
            lvaddr_t temp = ROUND_UP(node->base_addr + bytes, BASE_PAGE_SIZE);
            node->size -= (temp-node->base_addr);
            node->base_addr = temp;
            return SYS_ERR_OK;
        }
        node = node->next;
    }
    return LIB_ERR_OUT_OF_VIRTUAL_ADDR;
}
/**
 * TODO(M2): Implement this function
 * \brief Find a bit of free virtual address space that is large enough to
 *        accomodate a buffer of size `bytes`.
 */
Implement this function
\brief Find a bit of free virtual address space that is large enough to
accomodate a buffer of size `bytes`.
Implement this function \ brief Find a bit of free virtual address space that is large enough to accomodate a buffer of size ` bytes ` .
errval_t paging_alloc(struct paging_state *st, void **buf, size_t bytes)
{
    struct paging_frame_node *node = &st->free_node;
    while(node != NULL) {
        if(node->size >= bytes) {
            *buf = (void*)node->base_addr;
            lvaddr_t temp = ROUND_UP(node->base_addr + bytes, BASE_PAGE_SIZE);
            node->size -= (temp-node->base_addr);
            node->base_addr = temp;
            return SYS_ERR_OK;
        }
        node = node->next;
    }
    return LIB_ERR_OUT_OF_VIRTUAL_ADDR;
}
errval_t paging_alloc ( struct paging_state * st , void * * buf , size_t bytes ) { struct paging_frame_node * node = & st -> free_node ; while ( node != NULL ) { if ( node -> size >= bytes ) { * buf = ( void * ) node -> base_addr ; lvaddr_t temp = ROUND_UP ( node -> base_addr + bytes , BASE_PAGE_SIZE ) ; node -> size -= ( temp - node -> base_addr ) ; node -> base_addr = temp ; return SYS_ERR_OK ; } node = node -> next ; } return LIB_ERR_OUT_OF_VIRTUAL_ADDR ; }
TODO(M2): Implement this function
 \brief Find a bit of free virtual address space that is large enough to
        accomodate a buffer of size `bytes`.
TODO ( M2 ) : Implement this function \ brief Find a bit of free virtual address space that is large enough to accomodate a buffer of size ` bytes ` .