Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: VictorWTang <33789988+VictorWTang@users.noreply.github.com>
  • Loading branch information
multiplemonomials and VictorWTang authored Sep 21, 2024
1 parent 3d9a069 commit d5d76c9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tools/python/memap/memap.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@

@dataclasses.dataclass
class MemoryBankInfo:
# Name of the bank, from cmsis_mcu_descriptions.json
name: str
"""Name of the bank, from cmsis_mcu_descriptions.json"""

# Start address of memory bank
start_addr: int
"""Start address of memory bank"""

# Total size of the memory bank in bytes
total_size: int
"""Total size of the memory bank in bytes"""

# Size used in the memory bank in bytes (sum of the sizes of all symbols)
used_size: int = 0
"""Size used in the memory bank in bytes (sum of the sizes of all symbols)"""

def contains_addr(self, addr: int) -> bool:
"""
Expand All @@ -108,11 +108,11 @@ class _Parser(ABC):
'.stabstr', '.ARM.exidx', '.ARM')

def __init__(self):
# Dict of object name to {section name, size}
self.modules: dict[str, dict[str, int]] = {}
"""Dict of object name to {section name, size}"""

# Memory bank info, by type (RAM/ROM)
self.memory_banks: dict[str, list[MemoryBankInfo]] = {"RAM": [], "ROM": []}
"""Memory bank info, by type (RAM/ROM)"""

def _add_symbol_to_memory_banks(self, symbol_name: str, start_addr: int, size: int) -> None:
"""
Expand All @@ -124,7 +124,7 @@ def _add_symbol_to_memory_banks(self, symbol_name: str, start_addr: int, size: i
return

end_addr = start_addr + size
for bank_type, banks in self.memory_banks.items():
for banks in self.memory_banks.values():
for bank_info in banks:
if bank_info.contains_addr(start_addr):
if bank_info.contains_addr(end_addr):
Expand Down

0 comments on commit d5d76c9

Please sign in to comment.