Commit Graph

100 Commits

Author SHA1 Message Date
Harald Welte 32da9f931b vector.h: Add slot for openblt signature
The openblt boot loader needs one extra slot in the vector table in
order to store the signature and detect a valid boot image.
2021-03-28 21:40:42 +02:00
Jacob Potter 5b9b784b30 cm3: scb: add Cortex-M7 cache registers and bits
Cortex-M7 supports a D-cache and I-cache on the AXI bus, controlled by these bits in SCB.
2021-02-03 22:17:21 +00:00
Guillaume Revaillot 9d15ac7ae7 cortex: FAULTMASK does not exist on armv6m. 2020-01-04 21:53:34 +00:00
Karl Palsson 2b54119b78 cm3: scs: drop all duplicate information
Keeps the best version of the documentation.

Fixes: https://github.com/libopencm3/libopencm3/pull/269
2019-10-18 22:38:16 +00:00
Karl Palsson 833da4b672 cm3: extract SCB SHPR to the SCB world it belongs to
Pull out the duplicate into the right file, keeping the newly fixed
version.
2019-10-18 22:33:23 +00:00
Karl Palsson 3ebd71b464 cm3: extract Coresight LSR/LAR definitions
Use a single point of definition for the offset, and add it where it was
missing.
2019-10-18 22:29:13 +00:00
Matt Anderson d8579dde95 CortexM0: IPR and SHPR are only word addressable
For ARMv6M, the IPR and SHPR registers are accessible only when
adddressed with a 32bit word read or write.

Currently in libopencm3 all NVIC interrupt priority register accesses
are made using an 8bit read or write, which results in the hardware
ignoring the write or always returning 0 on read.

Address this by introducing NVIC_IPR32() and SCS_SHPR32() macro and
conditional implementation of nvic_set_priority when building for
cortex-m0.

See ARMv6M developer documentation:
IPR: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/Cihgjeed.html
SHPR: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/CIAGECDD.html
2019-10-17 21:26:13 +00:00
Guillaume Revaillot 1928e6eb3c doc: typo 2019-08-28 01:41:14 +00:00
Karl Palsson 1b10a0871c doc: cm3: mpu: fix typo 2019-06-25 21:15:19 +00:00
Karl Palsson 60991ac306 doc: cm3: nvic: convert existing docs to doxygen
Make it visible
2019-06-25 21:15:19 +00:00
Karl Palsson 69ce9f876f doc: core cm3: standard titles
easier on the eyes reading the list of docs
2019-06-25 21:15:19 +00:00
Karl Palsson d66c8677df doc: fix example syntax
@example is for including a file containing the example code.
2019-06-10 10:59:54 +00:00
Karl Palsson bc6af71443 doc: predefine a group for the cortex peripherals.
They were all trying to use this, via @ingroup CM3_files, but that group
didn't exist, so they just got left dangling as "systick_file" and
similar.
2019-05-21 21:41:41 +00:00
Karl Palsson 4edba3111d common: support inclusion into assembly files
Suggested in https://github.com/libopencm3/libopencm3/pull/981
2019-01-11 23:09:27 +00:00
Karl Palsson cae295ee2c doc: cm3/scb+scs: turn on existing documentation
Lots of registers were already documented extensively.  Turn it all in
doxygen with groups and the right syntax.
2018-09-09 15:27:41 +00:00
Karl Palsson 1ad2cda496 doc: add all cm3 headers to doxygen.
Just get them all included as they are.  Gets them grouped up and
visible so we can start clarifying the rest of their docs.
2018-09-09 15:27:41 +00:00
Karl Palsson 0c91dbf57e cm3: scs: drop (superseded) helper macros for systick
These are superseded by cm3/systick.h and the functions there.

Reported originally under: https://github.com/libopencm3/libopencm3/issues/125
2018-08-21 21:20:57 +00:00
Karl Palsson cfe514913f cm3: scs: drop (superseded) dwt macros
They are all superseded by dwt.h, and the function dwt_enable_cycle_counter

Fixes https://github.com/libopencm3/libopencm3/issues/125

(But only for the cycle count enabling)
2018-08-21 21:20:51 +00:00
keepkeyjon f53e12d2da cm3: Only inline asm is allowed in naked functions
According to: https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/ARM-Function-Attributes.html

"Only basic asm statements can safely be included in naked functions (see Basic
Asm). While using extended asm or a mixture of basic asm and C code may appear
to work, they cannot be depended upon to work reliably and are not supported."
2018-07-29 20:31:17 +00:00
Karl Palsson 38125e9941 vector: fix externs
Improper/lazy build testing.

Fixes: c6743f9 vector: make common linker definitions available to users
2017-10-18 20:51:33 +00:00
Karl Palsson c6743f9ecd vector: make common linker definitions available to users
_data_loadaddr, _data, _edata, _ebss, _stack and vector_table all now
available in vector.h.

Suggested on IRC
2017-10-18 20:05:14 +00:00
King Kévin 1f58917cb2 cm3: scb: rename SEVEONPEND to SEVONPEND
SEVEONPEND is a typo. According to the The ARM v7-M
Architecture Reference Manual SEVONPEND is the correct name.
2017-06-08 23:01:45 +00:00
Karl Palsson ed3cbffc2a cm3/sync.h: Add DECLS to allow use with c++
Reported by vvirag on IRC. Diagnosed and fixed by zyp on IRC
2017-01-27 17:08:37 +00:00
Henning W f974861cba cm3: SCB on M0/M0+ has SHCSR and DFSR regs too
SHCSR and DFSR are only implement on ARMv6 if the "Debug extension" is
implemented, but that's pretty much everywhere, so allow access to the
defines.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-12-17 01:01:40 +00:00
Devan Lai 011b5c615a cm3/fpb: Fix overly strict ARMv7 check 2016-11-05 13:54:09 -07:00
Anatol Pomozov ae41782e1a Fix misspellings using codespell tool 2016-03-08 08:52:54 -08:00
Karl Palsson ba9cb7dc5d minor stylecheck cleanups 2016-02-29 21:30:31 +00:00
fenugrec 1d36685759 Cortex: interrupt handling to use uint32_t instead of bool.
This is more in line with the actual hardware (u32 registers), and will still
work if PRIMASK or FAULTMASK ever have more than 1 bit defined.
The functions cm_is_masked_interrupts() and cm_is_masked_faults() are
unchanged, since returning 'bool' fits with the function naming.

Fixes most of github issue #475. What remains "unfixed" is the absence
of functions to simply 'get' the u32 value of PRIMASK and FAULTMASK registers.
2016-02-28 18:02:57 +00:00
Karl Palsson 58f9909474 cm3: remove duplicate confusing MPU defines.
The MPU RASR AP table has a duplicate entries for Privileged ReadOnly
and Usermode ReadOnly, in the source ARM document (Cortex M3 TRM)
Remove the duplicate here.

The MPU RASR Shareable, Bufferable and Cacheable bits are all individual
bits, and none of the existing defines appear to even match the ARM
documentation.  Remove them, but leave the definitions of the bit
positions.

Reported by MightyPork on IRC
2016-02-28 18:00:22 +00:00
fenugrec ad5ec6af08 Cortex-M defines : fix potential issue where PRIMASK and FAULTMASK operations could be optimized out by gcc.
This adds the "volatile" keyword to all the inline assembly. gcc docs say "You can prevent an asm instruction from being deleted by writing the keyword volatile after the asm.". Testing (see comments of github issue #475) shows that indeed gcc can remove some inline asm, in at least this situation:
-multiple calls to cm_is_masked_interrupts() in the same scope/context
- -Os or -O2 optimization
This is problem because the value of PRIMASK could change between two calls to cm_is_masked_interrupts().
Adding the volatile keyword fixes this, and probably costs less than adding a full barrier (like adding "memory" to the clobber list).
2016-01-10 11:13:25 -05:00
Jim Paris 01f08c4638 Remove WEAK from handler prototypes
These prototypes affect functions defined by application code.  Only
the implementations in libopencm3 are supposed to be weak; the
functions in application code should definitely not be.  Otherwise,
you'll end up with two weak symbols being linked together, and
it's luck as to which one the linker picks.
2015-11-24 09:55:27 +00:00
Karl Palsson c72f3d588a Surround all macro parameters with ()
All the macro arguments that are user supplied, or potentially, wrap properly
in () as good practice.

Probably missed one or two, and a lot of them are possibly unnecessary, but
it's straightforward to just do it always.

Fixes github issue #321
2015-10-14 22:15:15 +00:00
Karl Palsson f4d6da9554 cm3: MPU is optional on both v6m and v7m.
The MPU is an implementation option available for both ARMv6-M and ARMv7-M.
Remove poorly merged code that attempted to include this only for cortex m0+.

Added doxygen, updated the definitions of the RBAR register, (though if you're
really using this periperhal, you should be looking at the ref man for further
information)

Reported-by: forrestv on irc.
2015-08-16 13:35:35 +00:00
Karl Palsson aac78ba464 cm3: include stdint.h and stdbool.h
While there might be other places that are missing this include, this
particular file is clearly missing them, and has resulted in a few separate bug
reports.  Fix it right now, in the name of continuous improvement.

Fixes #310 and #427
2015-04-29 01:30:47 +00:00
Ondrej Palenicek 377f782d23 Removed extra underscore. 2015-02-05 18:27:29 -08:00
Oliver Meier a2fe6c49a8 [cm3/sync] Add mutex_trylock()
Allows non-blocking use in user code.
2014-12-11 09:58:34 +00:00
Frantisek Burian d96343d487 [FIX] Fix the ATOMIC suport. 2014-02-18 02:03:09 +01:00
Uwe Bonnes 86d35fe91c include/libopencm3/cm3/common.h: Fix CRLF. 2014-02-18 01:44:28 +01:00
bon@elektron.ikp.physik.tu-darmstadt.de 8b4ac9775e cm3/common.h: Cast addr in BBIO_xx() macros. BBIO_xx has 4 byte size. 2014-02-13 20:46:07 +01:00
Stefan Agner 7681597e42 Use type suffix to avoid warnings
When compiling with all warnings enabled, some defines can lead to
warning due to missing unsigned type suffix:

warning: integer overflow in expression [-Woverflow]

This fix should not affected behavior at all, since calculation with
such overflows lead to the same actual address when writing to that
location. However, it makes the warning disappear and also defines
the right data type for a memory location.
2014-02-06 00:59:39 +01:00
Frantisek Burian 5ba8b10428 Add method to clear the systick value, that is undefined at startup. 2014-01-15 22:37:45 +01:00
Piotr Esden-Tempski a909b5ca9e [Style] Global style fix run. 2014-01-03 01:07:30 +01:00
Frantisek Burian bfc65271c0 Remove compatibility with old systick.
Use only new names, from ARM manual, because systick.h is part of ARM core, not vendor.
2014-01-02 22:09:16 +01:00
Frantisek Burian d541c14110 [CM3] Systick Add helper function to easily set the desired frequency 2014-01-02 22:09:16 +01:00
Frantisek Burian 7ccc0d053e [CM3] Add register definitions for Debug Watch Trace point.
Add provision functions for the use of CPU counter as a high-resolution timer for code benchmarking purposes
2014-01-02 21:25:26 +01:00
BuFran aa9b94ee1d [Stylecheck] Correct style in the CM3 addition 2014-01-02 21:06:05 +01:00
Frantisek Burian 8e96592f55 [CM3] Add atomic operation support
Tested with -O0, -O2 and -Os generating correct code with gcc-arm-embedded 2013q2.
note -std=c99 or newer needed
2014-01-02 21:06:05 +01:00
Frantisek Burian 17fc71a462 [CM3] Add support for Cortex M interrupt masks
FIX: add doxygen documentation to the module
2014-01-02 21:06:05 +01:00
Frantisek Burian 065b47f8ba [CM3] Add core interrupt masking for easy creation of atomic blocks 2014-01-02 21:06:05 +01:00
Karl Palsson ec9fc5c122 [swo] Add/Update definitions necessary for SWO to work
ITM Stimulus ports need to be accessible with different sizes

The amount of data written out is determined by the size of the write.
Writing a full 32 bit value when you only need 8 for printf() style
substantially reduces the available bandwidth of the SWO

Note: this is an API change for doing 32bit writes.
Old:
    ITM_STIM[stimulus_port] = value
New:
    ITM_STIM32(stimulus_port) = value

This api is much more in common with some of the other registers that
behave this way.  As there's very little (if any) code already using
this API, it's a good time to fix it permanently.

Remove misleading ITM register definitions

ITM_SSPSR is the supported parallel trace size, in _bits_
ITM_CSPSR is in _bits_ as well.  There's really no advantage in even
having these sorts of definitions in libopencm3, as these settings are
normally controlled from the debugger side, not the target itself.

Lock and lock status register definitions were added, as per ARM:
  "For ARMv7-M, the component ID registers are required for the ROM table,
   and the CoreSight management lock access mechanism is defined for the
   DWT, ITM, FPB and TPIU blocks."
2013-11-21 16:21:38 +00:00