Exemple #1
0
struct buf * geteblk_special(size_t size, uint32_t control)
{
    struct proc_info * proc = proc_ref(0);
    const uintptr_t kvaddr = get_ksect_addr(size);
    struct buf * buf;
    int err;

    KASSERT(proc, "Can't get the PCB of pid 0");
    proc_unref(proc);

    if (kvaddr == 0) {
        KERROR_DBG("Returned kvaddr is NULL\n");
        return NULL;
    }

    buf = vm_newsect(kvaddr, size, VM_PROT_READ | VM_PROT_WRITE);
    if (!buf) {
        KERROR_DBG("vm_newsect() failed\n");
        return NULL;
    }

    buf->b_mmu.control = control;

    err = vm_insert_region(proc, buf, VM_INSOP_MAP_REG);
    if (err < 0) {
        panic("Mapping a kernel special buffer failed");
    }

    buf->b_data = buf->b_mmu.vaddr; /* Should be same as kvaddr */

    return buf;
}
Exemple #2
0
struct buf * geteblk_special(size_t size, uint32_t control)
{
    struct proc_info * p = proc_get_struct(0);
    const uintptr_t paddr = get_ksect_addr(size);
    struct vm_pt * vpt;
    struct buf * buf;

    if (!p)
        panic("Can't get the PCB of pid 0");

    if (paddr == 0)
        return NULL;

    buf = proc_newsect(paddr, size, VM_PROT_READ | VM_PROT_WRITE);
    if (!buf)
        return buf;

    buf->b_mmu.control = control;

    vpt = ptlist_get_pt(&p->mm.ptlist_head, &p->mm.mpt,
                        buf->b_mmu.vaddr);
    if (!vpt) {
        panic("Mapping a kernel special buffer failed");
    }

    buf->b_mmu.pt = &vpt->pt;
    vm_map_region(buf, vpt);
    vm_add_region(&p->mm, buf);

    buf->b_data = buf->b_mmu.vaddr;

    return buf;
}