# Path: VM/kernel/kernel.py
# class KernelMeta(type):   
# class Kernel(metaclass=KernelMeta):
#     def register(cls, syscall_number: int):
#         def actually_register(function: Callable[..., int]):
#     def __init__(self, cpu):
#     def __getitem__(self, syscall_number: int):
#     def kernel_read_string(self, address: int) -> bytes:


from .kernel import Kernel, Int, Uint
from ctypes import LittleEndianStructure, c_uint32, sizeof
        from ..Registers import SegmentDescriptor
import logging
    import enum
        logger.info('\tsys_brk: [SUCC] not changing break: 0x%08x == 0x%08x', oldbrk, newbrk)

        return kernel.cpu.mem.program_break

    if oldbrk > newbrk:
        # Remove invalid free blocks, if any.
        # A block is invalid if its starting address is greater or equal to the new BRK.
        cutoff = len(kernel.free_memory_blocks)
        for cutoff in range(cutoff - 1, -1, -1):
            s, e = kernel.free_memory_blocks[cutoff]

            if s < newbrk <= e:
                kernel.free_memory_blocks[cutoff] = s, newbrk
                cutoff -= 1
                break

        # `kernel.free_memory_blocks` is sorted, so `cutoff` chops off the invalid blocks
        kernel.free_memory_blocks = kernel.free_memory_blocks[:cutoff]

    kernel.cpu.mem.program_break = brk

    logger.info(
        '\tsys_brk: [SUCC] changing break: 0x%08x -> 0x%08x (%+d bytes)',
        oldbrk, kernel.cpu.mem.program_break, kernel.cpu.mem.program_break - oldbrk
    )

    return kernel.cpu.mem.program_break


@Kernel.register(0xc0)

# Path: VM/kernel/kernel.py
# class KernelMeta(type):   
# class Kernel(metaclass=KernelMeta):
#     def register(cls, syscall_number: int):
#         def actually_register(function: Callable[..., int]):
#     def __init__(self, cpu):
#     def __getitem__(self, syscall_number: int):
#     def kernel_read_string(self, address: int) -> bytes:


# Path: VM/kernel/kernel_memory.py
from .kernel import Kernel, Int, Uint
from ctypes import LittleEndianStructure, c_uint32, sizeof
        from ..Registers import SegmentDescriptor
import logging
    import enum

        logger.info('\tsys_brk: [SUCC] not changing break: 0x%08x == 0x%08x', oldbrk, newbrk)

        return kernel.cpu.mem.program_break

    if oldbrk > newbrk:
        # Remove invalid free blocks, if any.
        # A block is invalid if its starting address is greater or equal to the new BRK.
        cutoff = len(kernel.free_memory_blocks)
        for cutoff in range(cutoff - 1, -1, -1):
            s, e = kernel.free_memory_blocks[cutoff]

            if s < newbrk <= e:
                kernel.free_memory_blocks[cutoff] = s, newbrk
                cutoff -= 1
                break

        # `kernel.free_memory_blocks` is sorted, so `cutoff` chops off the invalid blocks
        kernel.free_memory_blocks = kernel.free_memory_blocks[:cutoff]

    kernel.cpu.mem.program_break = brk

    logger.info(
        '\tsys_brk: [SUCC] changing break: 0x%08x -> 0x%08x (%+d bytes)',
        oldbrk, kernel.cpu.mem.program_break, kernel.cpu.mem.program_break - oldbrk
    )

    return kernel.cpu.mem.program_break


@Kernel.register(0xc0)

def sys_mmap(kernel: Kernel, addr: Uint, length: Uint, prot: Int, flags: Int, fd: Int):