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

# Functions for poking at the MT1939's memory management hardware.

__all__ = [
    'overlay_set', 'overlay_get'
]


def overlay_set(d, address, wordcount = 1):
    """Set up a RAM overlay region, up to 4kB, mappable anywhere in the low 8MB."""

    if address & 3:
        raise ValueError("Overlay mapping address must be word aligned")

    control = 0x4011f04

    d.poke(control, d.peek(control) & ~0x200)
    d.poke(control, d.peek(control) & ~0x2000)
    d.poke(control + 0x0c, address)
    d.poke(control + 0x10, address + wordcount*4 - 1)
    d.poke(control, d.peek(control) | 0x200)
    d.poke(control, d.peek(control) | 0x2000)


def overlay_get(d):
    """Get the current extent of the RAM overlay"""

    control = 0x4011f04
    address = d.peek(control + 0x0c)
    limit = d.peek(control + 0x10)

    return (address, (limit - address + 3) / 4)<commit_msg>Punting on cache invalidate for now, add a warning comment<commit_after>#!/usr/bin/env python
import remote

# Functions for poking at the MT1939's memory management hardware.

__all__ = [
    'overlay_set', 'overlay_get'
]


def overlay_set(d, address, wordcount = 1):
    """Set up a RAM overlay region, up to 4kB, mappable anywhere in the low 8MB.

       WARNING: This mapping appears behind the instruction cache! If you've executed
                code in the mapping recently, changing the mapping won't necessarily
                work. To be sure, install the new mapping after a reset.
    """

    if address & 3:
        raise ValueError("Overlay mapping address must be word aligned")

    control = 0x4011f04

    d.poke(control, d.peek(control) & ~0x200)
    d.poke(control, d.peek(control) & ~0x2000)
    d.poke(control + 0x0c, address)
    d.poke(control + 0x10, address + wordcount*4 - 1)
    d.poke(control, d.peek(control) | 0x200)
    d.poke(control, d.peek(control) | 0x2000)


def overlay_get(d):
    """Get the current extent of the RAM overlay"""

    control = 0x4011f04
    address = d.peek(control + 0x0c)
    limit = d.peek(control + 0x10)

    return (address, (limit - address + 3) / 4)
{'fraction_non_alphanumeric': 0.11266947171575503, 'fraction_numerical': 0.05049088359046283, 'mean_word_length': 3.13926499032882, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7100092', 'n_tokens_mistral': 828, 'n_tokens_neox': 722, 'n_words': 226}