<commit_before>#!/usr/bin/env python
import remote, sys

# Set us up a trap for testing whether some code or data in Flash gets used.
# This sets up some memory mapping hardware to create a virtual region over
# the area we're trying to trap.
#
# This CANT CONTROL THE CONTENTS of the trap mapping yet! So anything could
# happen. Most likely, if the trapped area is in use, the firmware will crash.
# But really, anything.
#
# What does it do right now? It seems to pull 0x1000 bytes from 0xcfbe4 in flash.
# If the mapping is longer, the region repeats. The mapping can go anywhere in
# the low 8MB of virtual address space.
#
# Right now, here's what you get:
#    
#    In []: trap 7f_ 100
#    
#    In []: dis 7f_
#    007f0000    pop {r3, r4, r5, r6, r7, pc}
#    007f0002    push    {r0, r1, r4, r5, r6, r7, lr}
#    007f0004    movs    r7, r0
#    007f0006    movs    r0, #192    ; 0xc0
#    007f0008    sub sp, #4
#    007f000a    blx 0x007206d8
#    007f000e    ldr r2, [pc, #964]  ; (0x007f03d4)
#    007f0010    ldr r1, [r2, #4]
#    007f0012    asrs    r3, r2, #18
#    007f0014    orrs    r1, r3
#    007f0016    str r1, [r2, #4]
#    007f0018    ldr r1, [r2, #4]
#    007f001a    asrs    r3, r2, #17
#    007f001c    orrs    r1, r3
#
# So, in short, right now the "trap" implementation replaces any instruction
# you like with an instruction that copies:
#
#    r3 = [sp + 0]
#    r4 = [sp + 4]
#    r5 = [sp + 8]
#    r6 = [sp + c]
#    r7 = [sp + 10]
#    pc = [sp + 14]
#
# How about that sp+14?
#

__all__ = [
    'trap_set',
]


def trap_set(d, address, wordcount):
    # pulling from cfbe4

    control = 0x4011f04
    d.poke(control, d.peek(control) & ~0x200)<commit_msg>Formatting, defaults<commit_after>#!/usr/bin/env python
import remote, sys

# Set us up a trap for testing whether some code or data in Flash gets used.
# This sets up some memory mapping hardware to create a virtual region over
# the area we're trying to trap.
#
# This CANT CONTROL THE CONTENTS of the trap mapping yet! So anything could
# happen. Most likely, if the trapped area is in use, the firmware will crash.
# But really, anything.
#
# What does it do right now? It seems to pull up to 0x1000 bytes from 0xcfbe4
# in flash. If the mapping is longer, the region repeats. The mapping can go
# anywhere in the low 8MB of virtual address space.
#
# Right now, here's what you get:
#    
#    In []: trap 7f_ 100
#    
#    In []: dis 7f_
#    007f0000    pop {r3, r4, r5, r6, r7, pc}
#    007f0002    push    {r0, r1, r4, r5, r6, r7, lr}
#    007f0004    movs    r7, r0
#    007f0006    movs    r0, #192    ; 0xc0
#    007f0008    sub sp, #4
#    007f000a    blx 0x007206d8
#    007f000e    ldr r2, [pc, #964]  ; (0x007f03d4)
#    007f0010    ldr r1, [r2, #4]
#    007f0012    asrs    r3, r2, #18
#    007f0014    orrs    r1, r3
#    007f0016    str r1, [r2, #4]
#    007f0018    ldr r1, [r2, #4]
#    007f001a    asrs    r3, r2, #17
#    007f001c    orrs    r1, r3
#
# So, in short, right now the "trap" implementation replaces any instruction
# you like with an instruction that copies:
#
#    r3 = [sp + 0]
#    r4 = [sp + 4]
#    r5 = [sp + 8]
#    r6 = [sp + c]
#    r7 = [sp + 10]
#    pc = [sp + 14]
#
# How about that sp+14?
#

__all__ = [
    'trap_set',
]


def trap_set(d, address, wordcount = 1):
    # pulling from cfbe4

    control = 0x4011f04
    d.poke(control, d.peek(control) & ~0x200)
{'fraction_non_alphanumeric': 0.10748898678414097, 'fraction_numerical': 0.11365638766519824, 'mean_word_length': 2.4826175869120655, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5238748', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1338, 'n_words': 495}