mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
- Add root LICENSE (MIT License, Copyright (c) 2026 QuixiAI / Eric Hartford).
- Set license = "MIT" in workspace Cargo.toml and member crates (zero non-MIT dependencies).
- Update all kernel-open/ and tests/vm/ SPDX headers to MIT and EXPORT_SYMBOL_GPL -> EXPORT_SYMBOL.
- Use MODULE_LICENSE("Dual MIT/GPL") in Linux .ko modules so Linux modpost permits linking against the kernel's own EXPORT_SYMBOL_GPL symbols while keeping the repository source 100% MIT.
Closes #12.
51 lines
2.0 KiB
C
51 lines
2.0 KiB
C
// SPDX-License-Identifier: MIT
|
|
/* Exact Linux _ROM leaf used by580049576, with retained driver-owned PCI. */
|
|
#ifdef NV_RS_ROM_ACPI_HOST_FIXTURE
|
|
#include "rom_acpi_mock.h"
|
|
#else
|
|
#include <linux/acpi.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/preempt.h>
|
|
#include <linux/string.h>
|
|
#endif
|
|
#include "rom_acpi_adapter.h"
|
|
int nv_rs_rom_acpi_read(struct nv_rs_pci *pci,u32 offset,u32 bytes,
|
|
void *destination,u32 *nv_status)
|
|
{
|
|
int result=0;
|
|
if(!nv_status)return -EINVAL;
|
|
if(!destination){*nv_status=0x3d;return 0;}
|
|
if(bytes>4096){*nv_status=0x1f;return 0;}
|
|
if(!pci||!nv_rs_pci_get(pci))return -ENODEV;
|
|
if(nv_rs_pci_is_removed(pci)){result=-ENODEV;goto out;}
|
|
#if defined(CONFIG_ACPI) || defined(NV_RS_ROM_ACPI_HOST_FIXTURE)
|
|
{
|
|
struct device *device=nv_rs_pci_device(pci);
|
|
acpi_handle handle=device?ACPI_HANDLE(device):NULL;
|
|
struct acpi_buffer output={ACPI_ALLOCATE_BUFFER,NULL};
|
|
union acpi_object arguments[2],*rom;
|
|
struct acpi_object_list input={2,arguments};
|
|
acpi_status status;
|
|
if(!handle){*nv_status=0x1f;goto out;}
|
|
if(in_interrupt()||irqs_disabled()||in_atomic()){*nv_status=0x56;goto out;}
|
|
arguments[0].type=ACPI_TYPE_INTEGER;arguments[0].integer.value=offset;
|
|
arguments[1].type=ACPI_TYPE_INTEGER;arguments[1].integer.value=bytes;
|
|
status=acpi_evaluate_object(handle,"_ROM",&input,&output);
|
|
if(ACPI_FAILURE(status)){*nv_status=0xffff;kfree(output.pointer);goto out;}
|
|
rom=output.pointer;
|
|
if(!rom||rom->type!=ACPI_TYPE_BUFFER||rom->buffer.length<bytes||(!rom->buffer.pointer&&bytes)){
|
|
*nv_status=0xffff;kfree(output.pointer);goto out;
|
|
}
|
|
if(nv_rs_pci_is_removed(pci)){result=-ENODEV;kfree(output.pointer);goto out;}
|
|
if(bytes)memcpy(destination,rom->buffer.pointer,bytes);
|
|
kfree(output.pointer);*nv_status=0;
|
|
}
|
|
#else
|
|
(void)offset;
|
|
*nv_status=0x56;
|
|
#endif
|
|
out:
|
|
nv_rs_pci_put(pci);return result;
|
|
}
|