qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] QEMU as ISS (Instruction Set Simulator)


From: Aleksandar Markovic
Subject: Re: [Qemu-devel] QEMU as ISS (Instruction Set Simulator)
Date: Tue, 20 Aug 2019 12:42:30 +0200

On Tue, Aug 20, 2019 at 12:12 PM 立 <address@hidden> wrote:

> I am working on a project that requires me to modify the ISA of the MIPS
> target. I have been staring at the source code for about a week, but found
> it really difficult due to me being a young rookie and the sparse comments.
> Specifically, I need to extend MIPS, by adding some new instructions and
> new CPU registers to the current architecture, and that sounds really easy.
> I think the place for me to look at should be at the directory
> ${qemu_root}/target/mips/. With a MIPS Instruction Set Manual Release 6
> handy, I have difficulty finding the source code where the ISA resides. Is
> it in op_helper.c? Or translate.c? Any guidance would be really
> appreciated. Thank you very much in advance.
>
>
Let's say you want to add a new instruction to an ISA.

First, you need to define the layout of the binary code for that
instruction. This means some of the bits would determine registers that
contain input and output values for that instruction, and some of the bits
would be the ID (or, some would say, opcode) for that instruction. Perhaps
some other stuff to can be included here.

Once you settle the binary layout, you need to properly decode that
instruction, in one of many switch statements in translate.c.

After that, the main body of your work begin, You need to implement the
functionality you desire. There are two ways. If your functionality is
simple, as a rule, you would implement it using so called TCG (this is
just-in-time compiler inside QEMU). If your functionality is more complex,
you would implement it using C-functions called helpers. Those helpers
usually reside in op_helper.c, while TCG implementation usually reside
within translate.c.

After all this, you need to write a test program (that would be a little
tricky, since your new instruction will not be recognized by the compiler),
and execute it using QEMU.

I wish you an interesting journey into emulation!

Yours,
Aleksandar







>
> Cheers,
> L.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]