Skip to content

Commit f272690

Browse files
committed
Add missing definition for esp:partition_mmap/3
Also clarify semantics of `Offset` for all `partition_*` functions. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 8ef3849 commit f272690

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

libs/eavmlib/src/esp.erl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
partition_erase_range/2, partition_erase_range/3,
5151
partition_list/0,
5252
partition_read/3,
53+
partition_mmap/3,
5354
partition_write/3,
5455
rtc_slow_get_binary/0,
5556
rtc_slow_set_binary/1,
@@ -522,7 +523,7 @@ partition_list() ->
522523

523524
%%-----------------------------------------------------------------------------
524525
%% @param partition_id The id of the partition to read from eg. "main.avm"
525-
%% @param offset Starting offset in bytes where to begin reading
526+
%% @param offset Starting offset in the partition where to begin reading
526527
%% @param read_size Number of bytes to read
527528
%% @returns {ok, data} on success, error on failure
528529
%% @doc Read binary data from a specific partition at the given offset.
@@ -535,9 +536,26 @@ partition_list() ->
535536
partition_read(_Partition_id, _Offset, _Read_size) ->
536537
erlang:nif_error(undefined).
537538

539+
%%-----------------------------------------------------------------------------
540+
%% @param partition_id The id of the partition to read from eg. "main.avm"
541+
%% @param offset Starting offset in the partition where to begin reading
542+
%% @param read_size Number of bytes to read
543+
%% @returns {ok, data} on success, error on failure
544+
%% @doc Read binary data from a specific partition at the given offset,
545+
%% mapping it in RAM. The partition is unmapped when all references
546+
%% are garbage collected.
547+
%%
548+
%% @end
549+
%%-----------------------------------------------------------------------------
550+
-spec partition_mmap(
551+
Partition_id :: binary(), Offset :: non_neg_integer(), Read_size :: non_neg_integer()
552+
) -> {ok, binary()} | error.
553+
partition_mmap(_Partition_id, _Offset, _Read_size) ->
554+
erlang:nif_error(undefined).
555+
538556
%%-----------------------------------------------------------------------------
539557
%% @param partition_id The id of the partition to write to eg. "main.avm"
540-
%% @param offset Starting offset in bytes where to begin writing
558+
%% @param offset Starting offset in the partition where to begin writing
541559
%% @param data Binary data to write to the partition
542560
%% @returns ok on success, error on failure
543561
%% @doc Writes binary data to a specific partition at the given offset.

0 commit comments

Comments
 (0)