Skip to content

Commit a1fff34

Browse files
Fix video_set_framebuffer.
1 parent 81622d7 commit a1fff34

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ dual licensed as above, without any additional terms or conditions.
4242
### Unreleased Changes
4343

4444
* Changed `memory_get_region` to return a `MemoryRegion`
45+
* Changed `video_set_framebuffer` to take a `*const u8` not `*mut u8` - as the
46+
BIOS doesn't change video RAM.
4547

4648
### v0.3.0
4749

src/lib.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,28 @@ pub struct Api {
147147
pub video_get_framebuffer: extern "C" fn() -> *mut u8,
148148
/// Set the framebuffer address.
149149
///
150-
/// Tell the BIOS where it should start fetching pixel or textual data
151-
/// from (depending on the current video mode).
150+
/// Tell the BIOS where it should start fetching pixel or textual data from
151+
/// (depending on the current video mode).
152152
///
153153
/// This value is forgotten after a video mode change and must be
154154
/// re-supplied.
155-
pub video_set_framebuffer: extern "C" fn(*mut u8) -> crate::Result<()>,
156-
/// Find out how large a given region of memory is.
157155
///
158-
/// The first region is the 'application region' and is defined to always
159-
/// start at address `0x2000_0400` (that is, 1 KiB into main SRAM) on a
160-
/// standard Cortex-M system. This application region stops just before
161-
/// the BIOS reserved memory, at the top of the internal SRAM.
156+
/// Once the BIOS has handed over to the OS, it will never write to video
157+
/// memory, only read.
158+
///
159+
/// # Safety
160+
///
161+
/// The region pointed to by `start_address` must be large enough to contain
162+
/// however much video memory is required by both the current video mode,
163+
/// and whatever video modes you subsequently change into.
164+
pub video_set_framebuffer: unsafe extern "C" fn(start_address: *const u8) -> crate::Result<()>,
165+
/// Find out about regions of memory in the system.
166+
///
167+
/// The first region (index `0`) must be the 'application region' which is
168+
/// defined to always start at address `0x2000_0400` (that is, 1 KiB into
169+
/// main SRAM) on a standard Cortex-M system. This application region stops
170+
/// just before the BIOS reserved memory, typically at the top of the
171+
/// internal SRAM.
162172
///
163173
/// Other regions may be located at other addresses (e.g. external DRAM or
164174
/// PSRAM).

0 commit comments

Comments
 (0)