Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware & peripherals API #1466

Open
malexkiy opened this issue Apr 7, 2024 · 0 comments
Open

Hardware & peripherals API #1466

malexkiy opened this issue Apr 7, 2024 · 0 comments

Comments

@malexkiy
Copy link

malexkiy commented Apr 7, 2024

Please introduce public API for creating custom peripherals and managing hardware outside the framework's core.
Currently, it can be challenging to create a virtual SoC using existing APIs as only pre-defined MCUs are supported and hw blocks are instantiated from internal modules.

Also I'd like to have an ability to create dummy registers and map them to any address in the memory map.

Smth like this:

ql = Qiling(...)


class MyDummyReg(...):
    size: ClassVar = 2

    def read(self, ql: Qiling, addr: int) -> int:
        # do nothing or handle request
        ...

    def write(self, ql: Qiling, addr: int, value: int):
        # do nothing or handle request
        ...

    ...


ql.hw.add_reg("<bus_name>", 0xBEEFDEAD, MyDummyReg.size, "MyDummyReg", MyDummyReg())


class NandController(QlPeripheral):
    def read(self, offset: int, size: int) -> int:
        # map to file or read from a register
        ...

    def write(self, offset: int, size: int, value: int):
        # map to file or write to a register
        ...

    ...


ql.hw.add_peripheral("<bus_name>", 0xBEEF0000, "NandController", NandController())


class EthernetController(QlConnectivityPeripheral):
    def send(self, data: bytes):
        ...

    def recv(self, numb:int = 4096) -> bytes:
        ...

    def send_to_user(self, data: int):
        ...

    def recv_from_user(self) -> bytes:
        ...

    ...


ql.hw.add_connectivity_peripheral("<bus_name>", 0xBABE0000, "EthernetController", EthernetController())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant