Loading...
Searching...
No Matches
lock.h
1/*
2 * Copyright (c) 2024 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_BOOTROM_LOCK_H
8#define _PICO_BOOTROM_LOCK_H
9
10#include "hardware/boot_lock.h"
11#include "pico/bootrom_constants.h"
12
13// PICO_CONFIG: PICO_BOOTROM_LOCKING_ENABLED, Enable/disable locking for bootrom functions that use shared resources. If this flag is enabled bootrom lock checking is turned on and BOOT locks are taken around the relevant bootrom functions, type=bool, default=1, group=pico_bootrom
14#ifndef PICO_BOOTROM_LOCKING_ENABLED
15#if NUM_BOOT_LOCKS > 0
16#define PICO_BOOTROM_LOCKING_ENABLED 1
17#endif
18#endif
19
28static inline bool bootrom_try_acquire_lock(uint lock_num) {
29#if PICO_BOOTROM_LOCKING_ENABLED
30 // unsafe as this is a long term lock (so no irq disable)
32#else
33 (void)lock_num;
34 return true;
35#endif
36}
37
45static inline void bootrom_acquire_lock_blocking(uint lock_num) {
46#if PICO_BOOTROM_LOCKING_ENABLED
47 // unsafe as this is a long term lock (so no irq disable)
49#else
50 (void)lock_num;
51#endif
52}
53
61static inline void bootrom_release_lock(uint lock_num) {
62#if PICO_BOOTROM_LOCKING_ENABLED
64#else
65 (void)lock_num;
66#endif
67}
68
69#endif
static __force_inline bool boot_try_lock_unsafe(boot_lock_t *lock)
try to acquire a boot lock without disabling interrupts (hence unsafe)
Definition boot_lock.h:80
static __force_inline void boot_lock_unsafe_blocking(boot_lock_t *lock)
Acquire a boot lock without disabling interrupts (hence unsafe).
Definition boot_lock.h:65
static __force_inline void boot_unlock_unsafe(boot_lock_t *lock)
Release a boot lock without re-enabling interrupts.
Definition boot_lock.h:93
static __force_inline boot_lock_t * boot_lock_instance(uint lock_num)
Get HW Bootlock instance from number.
Definition boot_lock.h:42