# Path: awake/address.py
# BANK_SIZE = 0x4000
# class BadAddressException(Exception):
# class Address(object):
#     def __init__(self, addr):
#     def __str__(self):
# def fromVirtual(virtual):
# def fromVirtualAndBank(virtual, bank):
# def fromVirtualAndCurrent(virtual, current):
# def fromPhysical(physical):
# def fromConventional(conventional):
#     def __init__(self, address):
#     def virtual(self):
#     def bank(self):
#     def isAmbiguous(self):
#     def inBankedSpace(self):
#     def inPhysicalMem(self):
#     def physical(self):
#     def offset(self, offset):
#     def withBankSpecified(self, bank):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def __repr__(self):
# 
# Path: awake/operand.py
# class ProcAddress(AddressConstant):
#     link_prefix = "/proc/"
#     html_class = "proc-addr"
# 
# class DataAddress(AddressConstant):
#     link_prefix = "/data/"
#     html_class = "data-addr"
# 
# Path: awake/procedure.py
# def loadProcedureRange(proj, addr):
#     return ProcedureRangeAnalysis(proj, addr, getLimit(proj, addr))
# 
# Path: awake/jumptable.py
# class JumpTable(object):
#     def __init__(self, proj, addr):
#         self.addr = addr
#         self.targets = []
# 
#         for i in range(256):
#             a = addr.offset(i*2)
#             lo = proj.rom.get(a)
#             hi = proj.rom.get(a.offset(1))
#             value = address.fromVirtualAndCurrent((hi<<8) | lo, addr)
# 
#             if not value.inPhysicalMem():
#                 break
# 
#             self.targets.append(ProcAddress(value))
# 
#     def render(self, renderer):
#         with renderer.lineAddress(self.addr):
#             with renderer.comment():
#                 renderer.hline()
#                 renderer.startNewLine()
#                 renderer.write('jumptable ')
#                 renderer.writeSymbol(self.addr, 'jumptable')
#                 renderer.hline()
#         with renderer.indent():
#             i = 0
#             for t in self.targets:
#                 with renderer.lineAddress(self.addr.offset(i*2)):
#                     renderer.startNewLine()
#                     renderer.write(str(i) + ' -> ')
#                     t.render(renderer)
#                 i += 1


from awake import address
from awake.operand import ProcAddress, DataAddress
from awake.procedure import loadProcedureRange
from awake.jumptable import JumpTable
        self.proc = self.proj.flow.at(self.addr)

    def render(self, r):
        with r.lineAddress(self.addr), r.comment():
            r.hline()

            r.startNewLine()
            r.write("procedure flow ")
            r.writeSymbol(self.addr, 'procedure')

            r.startNewLine()
            r.write("  callers: ")
            r.writeList(ProcAddress(x) for x in sorted(self.info.callers))

            r.startNewLine()
            r.write("  calls: ")
            r.writeList(ProcAddress(x) for x in sorted(self.proc.calls()))

            r.hline()

        with r.indent():
            self.proc.render(r)

class ProcedureDisasmPage(Page):
    has_name_form = True

    def load(self):
        p = self.url.split('/')
        self.addr = address.fromConventional(p[2])
        self.info = self.proj.database.procInfo(self.addr)

# Path: awake/address.py
# BANK_SIZE = 0x4000
# class BadAddressException(Exception):
# class Address(object):
#     def __init__(self, addr):
#     def __str__(self):
# def fromVirtual(virtual):
# def fromVirtualAndBank(virtual, bank):
# def fromVirtualAndCurrent(virtual, current):
# def fromPhysical(physical):
# def fromConventional(conventional):
#     def __init__(self, address):
#     def virtual(self):
#     def bank(self):
#     def isAmbiguous(self):
#     def inBankedSpace(self):
#     def inPhysicalMem(self):
#     def physical(self):
#     def offset(self, offset):
#     def withBankSpecified(self, bank):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def __repr__(self):
# 
# Path: awake/operand.py
# class ProcAddress(AddressConstant):
#     link_prefix = "/proc/"
#     html_class = "proc-addr"
# 
# class DataAddress(AddressConstant):
#     link_prefix = "/data/"
#     html_class = "data-addr"
# 
# Path: awake/procedure.py
# def loadProcedureRange(proj, addr):
#     return ProcedureRangeAnalysis(proj, addr, getLimit(proj, addr))
# 
# Path: awake/jumptable.py
# class JumpTable(object):
#     def __init__(self, proj, addr):
#         self.addr = addr
#         self.targets = []
# 
#         for i in range(256):
#             a = addr.offset(i*2)
#             lo = proj.rom.get(a)
#             hi = proj.rom.get(a.offset(1))
#             value = address.fromVirtualAndCurrent((hi<<8) | lo, addr)
# 
#             if not value.inPhysicalMem():
#                 break
# 
#             self.targets.append(ProcAddress(value))
# 
#     def render(self, renderer):
#         with renderer.lineAddress(self.addr):
#             with renderer.comment():
#                 renderer.hline()
#                 renderer.startNewLine()
#                 renderer.write('jumptable ')
#                 renderer.writeSymbol(self.addr, 'jumptable')
#                 renderer.hline()
#         with renderer.indent():
#             i = 0
#             for t in self.targets:
#                 with renderer.lineAddress(self.addr.offset(i*2)):
#                     renderer.startNewLine()
#                     renderer.write(str(i) + ' -> ')
#                     t.render(renderer)
#                 i += 1


# Path: awake/pages.py
from awake import address
from awake.operand import ProcAddress, DataAddress
from awake.procedure import loadProcedureRange
from awake.jumptable import JumpTable

        self.proc = self.proj.flow.at(self.addr)

    def render(self, r):
        with r.lineAddress(self.addr), r.comment():
            r.hline()

            r.startNewLine()
            r.write("procedure flow ")
            r.writeSymbol(self.addr, 'procedure')

            r.startNewLine()
            r.write("  callers: ")
            r.writeList(ProcAddress(x) for x in sorted(self.info.callers))

            r.startNewLine()
            r.write("  calls: ")
            r.writeList(ProcAddress(x) for x in sorted(self.proc.calls()))

            r.hline()

        with r.indent():
            self.proc.render(r)

class ProcedureDisasmPage(Page):
    has_name_form = True

    def load(self):
        p = self.url.split('/')
        self.addr = address.fromConventional(p[2])
        self.info = self.proj.database.procInfo(self.addr)

        self.proc = loadProcedureRange(self.proj, self.addr)