Commit Graph
24 Commits
Author SHA1 Message Date
iceman1001andClaude Opus 5 461c252988 armsrc: fill words in memset, not just bytes
memcpy was taken off its byte-at-a-time loop in b66bb2659 and memset was left on
one, though the device memsets constantly and the loop is the same shape. This
gives it the same treatment, and it is the simpler of the two: with no source
buffer there is no alignment to match, so once the destination is word aligned
the word fill is always available.

Align the destination, build the fill word once, then store it four at a time
and singly for the remainder, with at most three bytes left over. Unrolled four
ways for the same reason memcpy is: at -Os the loop bookkeeping otherwise costs
more than the stores.

The bulk path goes from six instructions per byte to nine per sixteen bytes,
read off the disassembly:

    old   subs / cmp / bgt / strb / adds / b          per byte
    new   str x4 / adds / b, plus subs / cmp / bgt    per 16 bytes

Wall clock is not measured here. The closest anchor is memcpy's own figure from
b66bb2659, which measured 221us to 34us for a 624 byte aligned frame, and memset
has a store where memcpy has a load and a store.

Verified against libc memset on the host before flashing: 7224 cases, every
alignment from 0 to 7, every length from 0 to 300, and fill bytes 0x00, 0xFF and
0xA5, with no mismatches. Then on hardware, where a wrong memset would show up
everywhere rather than in one place: the DESFire simulation harness passes, and
hw status, hw tearoff, mem info, lf search, hf 14a info and hf mf info all
behave.

Builds for RDV4 and PM5.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 01:59:27 +02:00
iceman1001andClaude Opus 5 b66bb2659e armsrc: copy words in memcpy, not just bytes
The device ships its own string.c because there is no libc linked, and
memcpy was a byte at a time loop: six instructions per byte, 17 cycles
per byte measured, 221us for a 624 byte frame. Every copy on the device
paid that.

Take words when source and destination share their offset within a word,
which is the only case ARM7TDMI can do at all, and unroll the byte tail
four ways since at -Os the loop bookkeeping otherwise costs more than the
copy. 624 bytes aligned goes 221us -> 34us, misaligned 221 -> 125.

192 bytes, was 24. The bootrom does not link string.c.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 18:49:36 +02:00
Philippe Teuwen b703bb746b Adapting license headers, WIP 2022-01-06 02:20:38 +01:00
iceman1001 2d5aaaa335 conversion fixes 2021-04-16 22:30:53 +02:00
Philippe Teuwen 224cb2ffd7 make style 2020-06-08 03:15:10 +02:00
Philippe Teuwen 381b47f64e lz4: add memmove to arm string.c 2020-06-07 12:46:34 +02:00
iceman1001 c97775e907 style 2020-01-04 16:16:43 +01:00
iceman1001 2400418067 style 2019-08-01 11:15:39 -04:00
cjbrigato 3878f62168 HF_COLIN : Now able to read Known Mifare 1K key schemes from JSON Conf file from SPIFFS. BEWARE : DO NOT USE : Very Messy and early implementation 2019-07-31 01:32:16 +02:00
Philippe Teuwen 9beabaabf5 make style 2019-07-23 21:33:52 +02:00
cjbrigato 5c3676ad81 ADD: Early SPIFFS implementation see #257, UPDATE HF_COLIN accordingly 2019-07-22 22:56:06 +02:00
Philippe Teuwen 732bc766f9 Reduce some var scopes 2019-06-07 18:41:39 +02:00
osboxes.org 260ad9b7ae style 2019-04-10 09:32:55 +02:00
iceman1001 5585290981 fix: dereference 2019-04-08 11:40:52 +02:00
Philippe Teuwen 961d929f4d changing {} style to match majority of previous style 2019-03-10 11:20:22 +01:00
Philippe Teuwen 0373696662 make style 2019-03-10 00:00:59 +01:00
Philippe Teuwen 8a7c6825b5 armsrc: fix mix of spaces & tabs 2019-03-09 20:34:41 +01:00
Chris fe332a1f2b removed unneeded ramfunc attribute 2018-08-13 23:50:17 +02:00
iceman1001 07bc72b880 CHG: continue code cleanup.
REM: removed stdint.h ,  since we are using c99 when compiling.
2017-02-23 00:32:14 +01:00
iceman1001 897a14c36f CHG: moved to header file. common.h has RAMFUNC definition 2017-01-21 11:06:48 +01:00
iceman1001 f38a152863 First check in. 2014-09-11 23:23:46 +02:00
adam@algroup.co.uk 9455b51c2a Issue 20 patch (refactored code of the iso15693 implementation as well as several enhancements) [Adrian Dabrowski "atrox"] 2010-10-19 14:25:17 +00:00
marcansoft bd20f8f478 Add license headers to armsrc/bootrom/common stuff
I have kept whatever copyright notices exist. Please add your own
copyright notice if you have made any nontrivial changes or additions to
the code. There are several files without any attribution, currently.
2010-02-21 00:12:52 +00:00
marcansoft 9ab7a6c755 Split str* and mem* into string.[ch] 2010-02-21 00:10:28 +00:00