예제 #1
0
def w_pa(addr, buff, length=None):
    """Write physical address

        :param addr: The address to write
        :type addr: int

        :param buff: The buffer to write
        :type buffer: str

        :return: None
        :rtype: None
    """
    import c_api
    # The length parameter is not used at this moment,
    # but is kept to avoid breaking old scripts.
    if length is not None and len(buff) != length:
        raise ValueError(
            "Length of the buffer does not match the declared length")
    else:
        # If this function call fails, it will raise an exception.
        # Given that the exception is self explanatory, we just let it
        # propagate upwards
        offset = addr
        length = len(buff)
        while offset < (addr + length):
            write_length = 0x2000 if (addr + length - offset) > 0x2000 else (
                addr + length - offset)
            c_api.w_pa(offset,
                       buff[(offset - addr):(offset - addr + write_length)])
            offset += write_length
        return None
예제 #2
0
파일: api.py 프로젝트: CRYP706URU/pyrebox
def w_pa(addr, buff, length=None):
    """Write physical address

        :param addr: The address to write
        :type addr: int

        :param buff: The buffer to write
        :type buffer: str

        :return: None
        :rtype: None
    """
    import c_api
    # The length parameter is not used at this moment,
    # but is kept to avoid breaking old scripts.
    if length is not None and len(buff) != length:
        raise ValueError(
            "Length of the buffer does not match the declared length")
    else:
        # If this function call fails, it will raise an exception.
        # Given that the exception is self explanatory, we just let it
        # propagate upwards
        offset = addr
        length = len(buff)
        while offset < (addr + length):
            write_length = 0x2000 if (addr + length - offset) > 0x2000 else (addr + length - offset)
            c_api.w_pa(offset, buff[(offset - addr):(offset - addr + write_length)])
            offset += write_length
        return None
예제 #3
0
파일: api.py 프로젝트: zhouat/pyrebox
def w_pa(addr,buff,length):
    """Write physical address

        :param addr: The address to write
        :type addr: int

        :param buff: The buffer to write, between 0 and 0x2000 bytes
        :type buffer: str

        :param length: The length to write, between 0 and 0x2000 bytes
        :type length: int

        :return: None 
        :rtype: None
    """
    import c_api
    if len(buff) != length:
        raise ValueError("Length of the buffer does not match the declared length")
    else:
        #If this function call fails, it will raise an exception. 
        #Given that the exception is self explanatory, we just let it propagate upwards 
        return c_api.w_pa(addr,buff)