コード例 #1
0
ファイル: walker.c プロジェクト: tcsantini/libplatsupport
static void *
acpi_map_table(acpi_t *acpi, void *table_paddr)
{

    /* map the first part of the page in to read the size */
    acpi_header_t *header = (acpi_header_t *) ps_io_map(&acpi->io_mapper,
            (uintptr_t)table_paddr, sizeof(acpi_header_t), 1, PS_MEM_NORMAL);

    if (header == NULL) {
        fprintf(stderr, "Failed to map paddr %p, size %u\n", table_paddr, sizeof(acpi_header_t));
        assert(header != NULL);
        return NULL;
    }

    uint32_t length = acpi_table_length(header);
    if (length == 0xffffffff) {
        fprintf(stderr, "Skipping table %s, unknown\n", header->signature);
        return NULL;
    }

    /* if the size is bigger than a page, unmap and remap a contiguous region */
    if (!SAME_PAGE_4K(header, ((void *) header) + length)) {
        ps_io_unmap(&acpi->io_mapper, (void *) header, sizeof(acpi_header_t));
        header = ps_io_map(&acpi->io_mapper, (uintptr_t)table_paddr, length, 1, PS_MEM_NORMAL);

        if (header == NULL) {
            fprintf(stderr, "Failed tomap paddr %p, size %u\n", table_paddr, header->length);
            assert(header != NULL);
            return NULL;
        }
    }

    return header;
}
コード例 #2
0
ファイル: walker.c プロジェクト: tcsantini/libplatsupport
void*
acpi_sig_search(acpi_t *acpi, const char* sig, int sig_len, void* start, void* end)
{
    void *found = NULL;
    void *vaddr;

    /* work a page at a time, searching for the target string */
    while (start < end && !found) {
        vaddr = ps_io_map(&acpi->io_mapper, (uintptr_t) start, getpagesize(), 1, PS_MEM_NORMAL);
        if (vaddr == NULL) {
            fprintf(stderr, "Failed to map physical page %p\n", start);
            return NULL;
        }

        found = _sig_search(sig, sig_len, vaddr, vaddr + getpagesize());

        if (!found) {
            start += getpagesize();
        }

        ps_io_unmap(&acpi->io_mapper, vaddr, getpagesize());
    }

    if (!found) {
        fprintf(stderr, "Faied to find sig %s in range %p <-> %p\n", sig, start, end);
        return NULL;
    }

    /* return the physical address of sig */
    return (void *) start + ((uint32_t)found % getpagesize());
}
コード例 #3
0
ファイル: mux.c プロジェクト: seL4/util_libs
int
mux_sys_init(ps_io_ops_t *io_ops, mux_sys_t *mux)
{
    tegra_mux_state_t *state = malloc(sizeof(*state));
    if (!state) {
        ZF_LOGE("Failed to malloc");
        return 1;
    }
    state->pinmux_misc = (volatile void*)ps_io_map(&io_ops->io_mapper, MUX_PADDR_BASE, PAGE_SIZE_4K, 0, PS_MEM_NORMAL);
    if (!state->pinmux_misc) {
        ZF_LOGE("Failed to map pinmux page");
        free(state);
        return 1;
    }
    state->pinmux_aux = (volatile void*)ps_io_map(&io_ops->io_mapper, MUX_AUX_PADDR_BASE, PAGE_SIZE_4K, 0, PS_MEM_NORMAL);
    if (!state->pinmux_aux) {
        ZF_LOGE("Failed to map auxialiary pinmux page");
        ps_io_unmap(&io_ops->io_mapper, (void*)state->pinmux_misc, PAGE_SIZE_4K);
        free(state);
        return 1;
    }
    mux->priv = state;
    return tegra_mux_init_common(mux);
}
コード例 #4
0
ファイル: src.c プロジェクト: seL4/util_libs
int
reset_controller_init(enum src_id id, ps_io_ops_t* ops, src_dev_t* dev)
{
    /* Input bounds check */
    if (id < 0 || id >= NSRC) {
        return -1;
    }
    /* Map in the slcr registers */
    slcr_regs = ps_io_map(&ops->io_mapper, SLCR_PADDR, SLCR_SIZE, 0, PS_MEM_NORMAL);
    if (slcr_regs == NULL) {
        return -1;
    }
    slcr_set_regs(dev, slcr_regs);
    /* Unlock the reset controller registers */
    reset_controller_unlock(dev);
    return 0;
}