Skip to content

Commit 6552bfd

Browse files
authored
Merge pull request #1347 from nicholasbishop/bishop-book-proto
book: Update protocols how-to to use the `boot` module
2 parents a3e5f33 + 88ce336 commit 6552bfd

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

book/src/how_to/protocols.md

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ on that handle. See [Handles and Protocols] for an overview of what
55
these terms mean.
66

77
To get a handle you can use:
8-
* [`BootServices::locate_handle_buffer`]: this can be used to get _all_
8+
* [`boot::locate_handle_buffer`]: this can be used to get _all_
99
available handles, or just the handles that support a particular
1010
protocol.
11-
* [`BootServices::locate_handle`]: the same as `locate_handle_buffer`,
11+
* [`boot::locate_handle`]: the same as `locate_handle_buffer`,
1212
but you provide the slice that stores the handles.
13-
* [`BootServices::locate_device_path`]: find a handle by [Device Path].
13+
* [`boot::locate_device_path`]: find a handle by [Device Path].
1414

1515
Once you have obtained a handle, use
16-
[`BootServices::open_protocol_exclusive`] to open a protocol on that
16+
[`boot::open_protocol_exclusive`] to open a protocol on that
1717
handle. This returns a [`ScopedProtocol`], which automatically closes
1818
the protocol when dropped.
1919

20-
Using [`BootServices::open_protocol_exclusive`] is the safest way to
20+
Using [`boot::open_protocol_exclusive`] is the safest way to
2121
open a protocol, but in some cases a protocol cannot be opened in
22-
exclusive mode. The `unsafe` [`BootServices::open_protocol`] can be used
22+
exclusive mode. The `unsafe` [`boot::open_protocol`] can be used
2323
in that case.
2424

2525
## Example
@@ -63,12 +63,11 @@ The function starts by opening the [`LoadedImage`] protocol:
6363
{{#include ../../../uefi-test-runner/examples/loaded_image.rs:loaded_image}}
6464
```
6565

66-
The [`open_protocol_exclusive`] method takes a type parameter, which is
66+
The [`boot::open_protocol_exclusive`] method takes a type parameter, which is
6767
the type of [`Protocol`] you want to open ([`LoadedImage`] in this
6868
case). It also takes one regular argument of type [`Handle`]. For this
69-
example we want the handle of the currently-running image, which was
70-
passed in as the first argument to `main`. The handle is conveniently
71-
accessible through [`BootServices::image_handle`], so we use that here.
69+
example we want the handle of the currently-running image, conveniently
70+
accessible through [`boot::image_handle`].
7271

7372
Next the program opens the [`DevicePathToText`] protocol:
7473

@@ -77,9 +76,9 @@ Next the program opens the [`DevicePathToText`] protocol:
7776
```
7877

7978
This protocol isn't available for the `image_handle`, so we start by
80-
using [`locate_handle_buffer`] to find all handles that support
79+
using [`boot::locate_handle_buffer`] to find all handles that support
8180
`DevicePathToText`. We only need one handle though, so we call `first()`
82-
and discard the rest. Then we call [`open_protocol_exclusive`] again. It
81+
and discard the rest. Then we call [`boot::open_protocol_exclusive`] again. It
8382
looks more or less like the previous time, but with [`DevicePathToText`]
8483
as the type parameter and `device_path_to_text_handle` as the handle.
8584

@@ -98,13 +97,12 @@ reference documentation] and the [UEFI Specification].
9897
[Device Path]: ../concepts/device_paths.md
9998
[Handles and Protocols]: ../concepts/handles_and_protocols.md
10099
[UEFI Specification]: https://uefi.org/specifications
101-
[`BootServices::image_handle`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.image_handle
102-
[`BootServices::locate_device_path`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.locate_device_path
103-
[`BootServices::locate_handle_buffer`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.locate_handle_buffer
104-
[`BootServices::locate_handle`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.locate_handle
105-
[`BootServices::open_protocol`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.open_protocol
106-
[`BootServices::open_protocol_exclusive`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.open_protocol_exclusive
107-
[`BootServices`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html
100+
[`boot::image_handle`]: https://docs.rs/uefi/latest/uefi/boot/fn.image_handle.html
101+
[`boot::locate_device_path`]: https://docs.rs/uefi/latest/uefi/boot/fn.locate_device_path.html
102+
[`boot::locate_handle_buffer`]: https://docs.rs/uefi/latest/uefi/boot/fn.locate_handle_buffer.html
103+
[`boot::locate_handle`]: https://docs.rs/uefi/latest/uefi/boot/fn.locate_handle.html
104+
[`boot::open_protocol`]: https://docs.rs/uefi/latest/uefi/boot/fn.open_protocol.html
105+
[`boot::open_protocol_exclusive`]: https://docs.rs/uefi/latest/uefi/boot/fn.open_protocol_exclusive.html
108106
[`DevicePathToText`]: https://docs.rs/uefi/latest/uefi/proto/device_path/text/struct.DevicePathToText.html
109107
["Hello world!" example]: ../tutorial/app.html
110108
[`Handle`]: https://docs.rs/uefi/latest/uefi/data_types/struct.Handle.html
@@ -113,10 +111,7 @@ reference documentation] and the [UEFI Specification].
113111
[`OpenProtocolAttributes`]: https://docs.rs/uefi/latest/uefi/table/boot/enum.OpenProtocolAttributes.html
114112
[`OpenProtocolParams`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.OpenProtocolParams.html
115113
[`Protocol`]: https://docs.rs/uefi/latest/uefi/proto/trait.Protocol.html
116-
[`ScopedProtocol`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.ScopedProtocol.html
117-
[`locate_handle_buffer`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.locate_handle_buffer
118-
[`open_protocol`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.open_protocol
119-
[`open_protocol_exclusive`]: https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.open_protocol_exclusive
114+
[`ScopedProtocol`]: https://docs.rs/uefi/latest/uefi/boot/struct.ScopedProtocol.html
120115
[uefi-rs reference documentation]: https://docs.rs/uefi/latest/uefi/proto/index.html
121116
[`uefi::Result`]: https://docs.rs/uefi/latest/uefi/type.Result.html
122117
[`uefi::Status`]: https://docs.rs/uefi/latest/uefi/struct.Status.html

0 commit comments

Comments
 (0)