Skip to content

Commit

Permalink
Clarify the sbiret.value
Browse files Browse the repository at this point in the history
As per the calling convention a1 will have sbiret.value on ecall
return. However, the current specification describes an anlogous
C structure describing as long. Some of the SBI extension may require
an "unsigned long" data type instead of "long".

Relax the analgous C structure definition to allow that.

Fixes: #158

Signed-off-by: Atish Patra <[email protected]>
  • Loading branch information
atishp04 committed Nov 8, 2024
1 parent fd054bb commit a5c6415
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/binary-encoding.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ of SBI extensions. The SBI specification follows the below calling convention.
----
struct sbiret {
long error;
long value;
union {
long value;
unsigned long uvalue;
};
};
----

Expand Down
6 changes: 3 additions & 3 deletions src/ext-debug-console.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ XLEN bits of the input memory physical base address.
This is a non-blocking SBI call and it may do partial/no writes if
the debug console is not able to accept more bytes.

The number of bytes written is returned in `sbiret.value` and the
The number of bytes written is returned in `sbiret.uvalue` and the
possible error codes returned in `sbiret.error` are shown in
<<table_debug_console_write_errors>> below.

Expand Down Expand Up @@ -75,7 +75,7 @@ This is a non-blocking SBI call and it will not write anything
into the output memory if there are no bytes to be read in the
debug console.

The number of bytes read is returned in `sbiret.value` and the
The number of bytes read is returned in `sbiret.uvalue` and the
possible error codes returned in `sbiret.error` are shown in
<<table_debug_console_read_errors>> below.

Expand Down Expand Up @@ -106,7 +106,7 @@ This is a blocking SBI call and it will only return after writing
the specified byte to the debug console. It will also return, with
SBI_ERR_FAILED, if there are I/O errors.

The `sbiret.value` is set to zero and the possible error codes returned
The `sbiret.uvalue` is set to zero and the possible error codes returned
in `sbiret.error` are shown in <<table_debug_console_write_byte_errors>>
below.

Expand Down
8 changes: 4 additions & 4 deletions src/ext-mpxy.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ passed accordingly. The supervisor software may require multiple SBI calls to
get the complete list of channel IDs depending on the `RETURNED` and
`REMAINING` fields.

The `sbiret.value` is always set to zero whereas the possible error codes
The `sbiret.uvalue` is always set to zero whereas the possible error codes
returned in `sbiret.error` are below.

[#table_sbi_mpxy_get_channel_ids_errors]
Expand Down Expand Up @@ -598,15 +598,15 @@ specifications.

Upon calling this function the SBI implementation MUST write the response
message data at the offset `0x0` in the shared memory setup by the calling hart
and the number of bytes written will be returned through `sbiret.value`.
and the number of bytes written will be returned through `sbiret.uvalue`.
The layout of data in case of both request and response is according to the
respective message protocol specification message format.

Upon success, this function: +
1) Writes the message response data at offset `0x0` of the shared memory setup
by the calling hart. +
2) Returns `SBI_SUCCESS` in `sbiret.error`. +
3) Returns message response data length in `sbiret.value`. +
3) Returns message response data length in `sbiret.uvalue`. +

This function is optional. If this function is implemented, the corresponding
bit in the `CHANNEL_CAPABILITY` attribute is set to `1`.
Expand Down Expand Up @@ -769,7 +769,7 @@ SBI implementation at the offset `0x10` in the shared memory setup by the
calling hart irrespective of events state data reporting. If events state data
reporting is disabled or not supported, then the values in events state fields
are undefined. The number of the bytes written to the shared memory will be
returned through `sbiret.value` which is the number of bytes starting from
returned through `sbiret.uvalue` which is the number of bytes starting from
offset `0x10`. The layout and encoding of notification events are defined by
the message protocol specification associated with the message proxy channel
(`channel_id`).
Expand Down

0 comments on commit a5c6415

Please sign in to comment.