Skip to content

MARS Tool Syscalls#22

Open
xarkenz wants to merge 4 commits into
devfrom
tool-syscalls
Open

MARS Tool Syscalls#22
xarkenz wants to merge 4 commits into
devfrom
tool-syscalls

Conversation

@xarkenz

@xarkenz xarkenz commented Jan 17, 2025

Copy link
Copy Markdown
Owner

Added three new syscalls: LaunchTool (62), which launches a given tool in the GUI if it is not already open; NotifyTool (63), which effectively sends a signal to a given tool which is handled in a manner defined by the tool; and QueryTool (64), which is very similar to NotifyTool but is intended to request values from the tool rather than provide values to it. The goal of this feature is to provide a mechanism for MIPS programs to interface directly with the set of MARS tools. For example, the parameters of the Bitmap Display can be set by the program at runtime, rather than requiring manual setup by the user beforehand.

Each existing tool has been assigned an "identifier" string (such as bitmap for Bitmap Display and visualstack for Visual Stack) which is used to determine which tool is being referred to when one of the aforementioned syscalls occurs. Each syscall reads a null-terminated string from the address in $a0 and interprets it as the tool identifier.

Below is a simple example fragment to demonstrate the utility these syscalls provide. The result of executing this code is that the Bitmap Display is launched automatically and the base address for the bitmap is set to the address of label screen.

    .data
BitmapDisplay:
    .asciiz "bitmap"
screen:
    .space 0x4000
    .text
    ...
    li $v0, 62 # launch tool
    la $a0, BitmapDisplay
    syscall
    li $v0, 63 # notify tool
    la $a0, BitmapDisplay
    li $a1, 1 # base address key
    la $a2, screen # Bitmap Display reads $a2 to get value
    syscall
    ...

Internally, the NotifyTool and QueryTool syscalls themselves are virtually identical-- they look up the tool using $a0 and call a method (handleNotify / handleQuery) on the tool, passing in the value of $a1 as the "key." The purpose of the key is defined by the tool, but the default implementation given by AbstractMarsTool uses the key to select a query / notify handler to run. Tools extending AbstractMarsTool can then use the addNotifyHandler and addQueryHandler methods to define these handlers.

At the moment, the Bitmap Display is the only tool supporting NotifyTool and QueryTool. The goal is to support this feature in all applicable tools-- this pull request is intended to lay the groundwork for future refinement.

@xarkenz xarkenz added the enhancement New feature or request label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant