···2525 slot_ptr(id).cast()
2626}}
27272828+pub fn slot_of_addr<T>(addr: *const T) -> u8 {
2929+ ((addr as usize - XIP_BASE as usize) / SLOT_SIZE) as u8
3030+}
3131+28322933pub struct Programs {
3034 id: u8,
···208212 self.bss_vma.write_bytes(0, self.bss_len);
209213 }
210214 }}
215215+}
216216+217217+/// Get the slot number of the (first) program with the specified name, if it exists.
218218+pub fn find_program_by_name(name: &str) -> Option<u8> {
219219+ Programs::new()
220220+ .find(|psh| {
221221+ // SAFETY: a header returned by Programs must be valid
222222+ let prog_name = unsafe { (**psh).name() };
223223+ prog_name == Ok(name)
224224+ })
225225+ .map(slot_of_addr)
211226}