Example #1
0
static int __init acpi_read_sdt_at(void *sdt_va,
                                   struct acpi_sdt_hdr * tb,
                                   size_t size,
                                   const char * name)
{
    struct acpi_sdt_hdr hdr;

    /* if NULL is supplied, we only return the size of the table */
    if (tb == NULL) {
        memcpy(&hdr, sdt_va, sizeof(struct acpi_sdt_hdr));
        return hdr.len;
    }

    memcpy(tb, sdt_va, sizeof(struct acpi_sdt_hdr));

    if (acpi_check_signature((const char *)tb->signature,
                             (const char *)name)) {
        vmm_printf("ACPI ERROR: acpi %s signature does not match\n", name);
        return VMM_EFAIL;
    }

    if (size < tb->len) {
        vmm_printf("ACPI ERROR: acpi buffer too small for %s\n", name);
        return VMM_EFAIL;
    }

    memcpy(tb, sdt_va, size);

    if (acpi_check_csum(tb, tb->len)) {
        vmm_printf("ACPI ERROR: acpi %s checksum does not match\n", name);
        return VMM_EFAIL;
    }

    return tb->len;
}
Example #2
0
static int
read_sdt_at(uintptr_t addr, acpi_sdt_header *tb, size_t size,  const char *name){
	int rc;

	acpi_copy_phys(addr, tb, sizeof(acpi_sdt_header));
	rc = memcmp(tb->signature, name, ACPI_SDT_SIGNATURE_LEN);
	if ( rc != 0 ) {

		kprintf("ERROR ACPI signature does not match with %s\n", name);
		return -1;
	}
	
	if (size < tb->length) {
		kprintf("ERROR ACPI buffer too small for %s\n", name);
		return -1;
	}

	acpi_copy_phys(addr, tb, size);
	rc = acpi_check_csum(tb, tb->length);
	if ( rc != 0 ) {

		kprintf("ERROR acpi %s checksum does not match\n", name);
		return -1;
	}

	return tb->length;
}
Example #3
0
File: acpi.c Project: Hooman3/minix
static int acpi_read_sdt_at(phys_bytes addr,
				struct acpi_sdt_header * tb,
				size_t size,
				const char * name)
{
	struct acpi_sdt_header hdr;

	/* if NULL is supplied, we only return the size of the table */
	if (tb == NULL) {
		if (read_func(addr, &hdr, sizeof(struct acpi_sdt_header))) {
			printf("ERROR acpi cannot read %s header\n", name);
			return -1;
		}

		return hdr.length;
	}

	if (read_func(addr, tb, sizeof(struct acpi_sdt_header))) {
		printf("ERROR acpi cannot read %s header\n", name);
		return -1;
	}

	if (acpi_check_signature(tb->signature, name)) {
		printf("ERROR acpi %s signature does not match\n", name);
		return -1;
	}

	if (size < tb->length) {
		printf("ERROR acpi buffer too small for %s\n", name);
		return -1;
	}

	if (read_func(addr, tb, size)) {
		printf("ERROR acpi cannot read %s\n", name);
		return -1;
	}

	if (acpi_check_csum(tb, tb->length)) {
		printf("ERROR acpi %s checksum does not match\n", name);
		return -1;
	}

	return tb->length;
}
Example #4
0
static int acpi_read_sdt_at(physical_addr_t addr,
                            struct acpi_sdt_hdr * tb,
                            size_t size,
                            const char * name)
{
    struct acpi_sdt_hdr hdr;
    void *sdt_va = NULL;

    sdt_va = (void *)vmm_host_iomap(addr, PAGE_SIZE);
    if (unlikely(!sdt_va)) {
        vmm_printf("ACPI ERROR: Failed to map physical address 0x%x.\n",
                   __func__, addr);
        return VMM_EFAIL;
    }

    /* if NULL is supplied, we only return the size of the table */
    if (tb == NULL) {
        vmm_memcpy(&hdr, sdt_va, sizeof(struct acpi_sdt_hdr));
        return hdr.len;
    }

    vmm_memcpy(tb, sdt_va, sizeof(struct acpi_sdt_hdr));

    if (acpi_check_signature((const char *)tb->signature,
                             (const char *)name)) {
        vmm_printf("ACPI ERROR: acpi %s signature does not match\n", name);
        return VMM_EFAIL;
    }

    if (size < tb->len) {
        vmm_printf("ACPI ERROR: acpi buffer too small for %s\n", name);
        return VMM_EFAIL;
    }

    vmm_memcpy(tb, sdt_va, size);

    if (acpi_check_csum(tb, tb->len)) {
        vmm_printf("ACPI ERROR: acpi %s checksum does not match\n", name);
        return VMM_EFAIL;
    }

    return tb->len;
}