mirror of
https://github.com/LIV2/amitools.git
synced 2025-12-06 06:32:47 +00:00
xdftools: fixed bitmap dump
This commit is contained in:
parent
6c74b0235d
commit
0bd6eb5dba
@ -32,7 +32,6 @@ class ELFDumper:
|
||||
print("ELF Sections")
|
||||
print("id name size rela syms type flags")
|
||||
for sect in self.elf.sections:
|
||||
|
||||
# determine number of relocations
|
||||
rela = sect.get_rela()
|
||||
num_rela = len(rela)
|
||||
|
||||
@ -315,7 +315,7 @@ class ADFSBitmap:
|
||||
res = self.blkdev.reserved
|
||||
for i in range(self.blkdev.num_blocks):
|
||||
if i >= res and self.get_bit(i):
|
||||
bm[i] = "F"
|
||||
bm[i] = ord("F")
|
||||
self.print_draw_bitmap(bm, brief)
|
||||
|
||||
def print_used(self, brief=False):
|
||||
@ -323,39 +323,39 @@ class ADFSBitmap:
|
||||
res = self.blkdev.reserved
|
||||
for i in range(self.blkdev.num_blocks):
|
||||
if i >= res and not self.get_bit(i):
|
||||
bm[i] = "#"
|
||||
bm[i] = ord("#")
|
||||
self.print_draw_bitmap(bm, brief)
|
||||
|
||||
def draw_on_bitmap(self, bm):
|
||||
# show reserved blocks
|
||||
res = self.blkdev.reserved
|
||||
bm[0:res] = "x" * res
|
||||
bm[0:res] = b"x" * res
|
||||
# root block
|
||||
bm[self.root_blk.blk_num] = "R"
|
||||
bm[self.root_blk.blk_num] = ord("R")
|
||||
# bitmap blocks
|
||||
for bm_blk in self.bitmap_blks:
|
||||
bm[bm_blk.blk_num] = "b"
|
||||
bm[bm_blk.blk_num] = ord("b")
|
||||
# bitmap ext blocks
|
||||
for ext_blk in self.ext_blks:
|
||||
bm[ext_blk.blk_num] = "B"
|
||||
bm[ext_blk.blk_num] = ord("B")
|
||||
|
||||
def print_draw_bitmap(self, bm, brief=False):
|
||||
line = ""
|
||||
line = bytearray()
|
||||
blk = 0
|
||||
blk_cyl = self.blkdev.sectors * self.blkdev.heads
|
||||
found = False
|
||||
for i in range(self.blkdev.num_blocks):
|
||||
c = bm[i]
|
||||
if ord(c) == 0:
|
||||
c = "."
|
||||
if c == 0:
|
||||
c = ord(".")
|
||||
else:
|
||||
found = True
|
||||
line += c
|
||||
line.append(c)
|
||||
if i % self.blkdev.sectors == self.blkdev.sectors - 1:
|
||||
line += " "
|
||||
line.append(ord(" "))
|
||||
if i % blk_cyl == blk_cyl - 1:
|
||||
if not brief or found:
|
||||
print("%8d: %s" % (blk, line))
|
||||
print("%8d: %s" % (blk, line.decode("utf-8")))
|
||||
blk += blk_cyl
|
||||
line = ""
|
||||
line = bytearray()
|
||||
found = False
|
||||
|
||||
@ -374,14 +374,14 @@ class ADFSDir(ADFSNode):
|
||||
|
||||
def draw_on_bitmap(self, bm, show_all=False, first=True):
|
||||
blk_num = self.block.blk_num
|
||||
bm[blk_num] = "D"
|
||||
bm[blk_num] = ord("D")
|
||||
if show_all or first:
|
||||
self.ensure_entries()
|
||||
for e in self.entries:
|
||||
e.draw_on_bitmap(bm, show_all, False)
|
||||
if self.dcache_blks != None:
|
||||
for dcb in self.dcache_blks:
|
||||
bm[dcb.blk_num] = "C"
|
||||
bm[dcb.blk_num] = ord("C")
|
||||
|
||||
def get_block_nums(self):
|
||||
self.ensure_entries()
|
||||
|
||||
@ -275,11 +275,11 @@ class ADFSFile(ADFSNode):
|
||||
left -= bs
|
||||
|
||||
def draw_on_bitmap(self, bm, show_all=False, first=False):
|
||||
bm[self.block.blk_num] = "H"
|
||||
bm[self.block.blk_num] = ord("H")
|
||||
for b in self.ext_blk_nums:
|
||||
bm[b] = "E"
|
||||
bm[b] = ord("E")
|
||||
for b in self.data_blk_nums:
|
||||
bm[b] = "d"
|
||||
bm[b] = ord("d")
|
||||
|
||||
def get_block_nums(self):
|
||||
result = [self.block.blk_num]
|
||||
|
||||
@ -18,7 +18,7 @@ class ADFSVolDir(ADFSDir):
|
||||
|
||||
def draw_on_bitmap(self, bm, show_all=False, first=True):
|
||||
blk_num = self.block.blk_num
|
||||
bm[blk_num] = "V"
|
||||
bm[blk_num] = ord("V")
|
||||
if show_all or first:
|
||||
self.ensure_entries()
|
||||
for e in self.entries:
|
||||
|
||||
@ -17,7 +17,6 @@ from .MetaInfoFSUAE import MetaInfoFSUAE
|
||||
|
||||
|
||||
class Imager:
|
||||
|
||||
META_MODE_NONE = 0
|
||||
META_MODE_DB = 1
|
||||
META_MODE_FSUAE = 2
|
||||
|
||||
@ -2,7 +2,6 @@ from .BlockDevice import BlockDevice
|
||||
|
||||
|
||||
class ADFBlockDevice(BlockDevice):
|
||||
|
||||
# number of total sectors for DD/HD disks
|
||||
DD_SECS = 80 * 2 * 11
|
||||
HD_SECS = 80 * 2 * 22
|
||||
|
||||
@ -62,6 +62,9 @@ class Block:
|
||||
def is_comment_block(self):
|
||||
return self.type == Block.T_COMMENT
|
||||
|
||||
def is_dir_cache_block(self):
|
||||
return self.type == Block.T_DIR_CACHE
|
||||
|
||||
def read(self):
|
||||
if self.data == None:
|
||||
self._read_data()
|
||||
|
||||
33
amitools/fs/block/BlockFactory.py
Normal file
33
amitools/fs/block/BlockFactory.py
Normal file
@ -0,0 +1,33 @@
|
||||
from .Block import Block
|
||||
from .RootBlock import RootBlock
|
||||
from .UserDirBlock import UserDirBlock
|
||||
from .FileHeaderBlock import FileHeaderBlock
|
||||
from .FileListBlock import FileListBlock
|
||||
from .FileDataBlock import FileDataBlock
|
||||
from .CommentBlock import CommentBlock
|
||||
from .DirCacheBlock import DirCacheBlock
|
||||
|
||||
|
||||
class BlockFactory:
|
||||
@classmethod
|
||||
def create_block(cls, blkdev, blk_num, type, sub_type):
|
||||
if type == Block.T_SHORT:
|
||||
if sub_type == Block.ST_ROOT:
|
||||
return RootBlock(blkdev, blk_num)
|
||||
elif sub_type == Block.ST_USERDIR:
|
||||
return UserDirBlock(blkdev, blk_num)
|
||||
elif sub_type == Block.ST_FILE:
|
||||
return FileHeaderBlock(blkdev, blk_num)
|
||||
elif type == Block.T_LIST:
|
||||
if sub_type == Block.ST_FILE:
|
||||
return FileListBlock(blkdev, blk_num)
|
||||
elif type == Block.T_DATA:
|
||||
return FileDataBlock(blkdev, blk_num)
|
||||
elif type == Block.T_COMMENT:
|
||||
return CommentBlock(blkdev, blk_num)
|
||||
elif type == Block.T_DIR_CACHE:
|
||||
return DirCacheBlock(blkdev, blk_num)
|
||||
|
||||
@classmethod
|
||||
def create_specific_block(cls, block):
|
||||
return cls.create_block(block.blkdev, block.blk_num, block.type, block.sub_type)
|
||||
@ -6,7 +6,7 @@ from ..FSString import FSString
|
||||
|
||||
|
||||
class UserDirBlock(EntryBlock):
|
||||
def __init__(self, blkdev, blk_num, is_longname):
|
||||
def __init__(self, blkdev, blk_num, is_longname=False):
|
||||
EntryBlock.__init__(
|
||||
self,
|
||||
blkdev,
|
||||
|
||||
@ -137,7 +137,6 @@ class BootConRomPatch(RomPatch):
|
||||
|
||||
|
||||
class RomPatcher:
|
||||
|
||||
# list of all available patch classes
|
||||
patches = [OneMegRomPatch(), FourMegRomPatch(), BootConRomPatch()]
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ import amitools.util.KeyValue as KeyValue
|
||||
import amitools.util.ByteSize as ByteSize
|
||||
import amitools.util.VerTag as VerTag
|
||||
|
||||
|
||||
# ----- commands -----
|
||||
class Command:
|
||||
def __init__(self, args, opts, edit=False):
|
||||
|
||||
@ -14,6 +14,8 @@ from amitools.fs.Imager import Imager
|
||||
from amitools.fs.Repacker import Repacker
|
||||
from amitools.fs.block.BootBlock import BootBlock
|
||||
from amitools.fs.block.RootBlock import RootBlock
|
||||
from amitools.fs.block.Block import Block
|
||||
from amitools.fs.block.BlockFactory import BlockFactory
|
||||
from amitools.util.CommandQueue import CommandQueue
|
||||
from amitools.util.HexDump import *
|
||||
import amitools.util.KeyValue as KeyValue
|
||||
@ -567,7 +569,7 @@ class BlockCmd(Command):
|
||||
n = len(self.opts)
|
||||
if n == 0:
|
||||
print(
|
||||
"Usage: block ( boot | root | node <ami_file> [data] | dump <block_no> )"
|
||||
"Usage: block ( boot | root | node <ami_file> [data] | dump <block_no> | decode <block_no> )"
|
||||
)
|
||||
return 1
|
||||
cmd = self.opts[0]
|
||||
@ -600,6 +602,24 @@ class BlockCmd(Command):
|
||||
block_no = int(self.opts[1])
|
||||
data = vol.blkdev.read_block(block_no)
|
||||
print_hex(data)
|
||||
elif cmd == "decode":
|
||||
if n == 1:
|
||||
print("No block number given!")
|
||||
return 1
|
||||
else:
|
||||
block_no = int(self.opts[1])
|
||||
# read block
|
||||
blk = Block(vol.blkdev, block_no)
|
||||
blk.read()
|
||||
if blk.valid:
|
||||
dec_blk = BlockFactory.create_specific_block(blk)
|
||||
if dec_blk:
|
||||
dec_blk.read()
|
||||
dec_blk.dump()
|
||||
else:
|
||||
blk.dump("Unknown")
|
||||
else:
|
||||
print("Error reading block!")
|
||||
|
||||
|
||||
# ----- Bitmap Tools -----
|
||||
|
||||
@ -3,7 +3,6 @@ from .pointer import BCPLPointerType
|
||||
|
||||
|
||||
class AccessStruct(object):
|
||||
|
||||
_size_to_width = [None, 0, 1, None, 2]
|
||||
|
||||
def __init__(self, mem, struct_def, struct_addr):
|
||||
|
||||
@ -46,7 +46,6 @@ FieldDefBase = collections.namedtuple(
|
||||
|
||||
|
||||
class FieldDef(FieldDefBase):
|
||||
|
||||
_base_offset = 0
|
||||
_parent_def = None
|
||||
|
||||
@ -322,7 +321,6 @@ class AmigaStructFields:
|
||||
|
||||
|
||||
class AmigaStruct(TypeBase):
|
||||
|
||||
# overwrite in derived class!
|
||||
_format = None
|
||||
# top-level alias names for subfields
|
||||
|
||||
@ -39,7 +39,6 @@ class AmigaStructDecorator(object):
|
||||
|
||||
# run through fields
|
||||
for field_type, field_name in format:
|
||||
|
||||
# replace self pointers
|
||||
if field_type is APTR_SELF:
|
||||
field_type = APTR(cls)
|
||||
|
||||
@ -10,7 +10,6 @@ from .Error import *
|
||||
|
||||
|
||||
class MatchFirstNext:
|
||||
|
||||
DODIR = 4
|
||||
DIDDIR = 8
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ from amitools.vamos.error import *
|
||||
|
||||
|
||||
class SemaphoreManager:
|
||||
|
||||
NT_SIGNALSEM = 15
|
||||
|
||||
def __init__(self, alloc, mem):
|
||||
|
||||
@ -241,7 +241,6 @@ class LibProfileData(object):
|
||||
|
||||
|
||||
class LibProfiler(Profiler):
|
||||
|
||||
name = "libs"
|
||||
|
||||
def __init__(self, names=None, add_calls=False, add_all=False):
|
||||
|
||||
@ -82,7 +82,6 @@ class InitStruct(object):
|
||||
|
||||
|
||||
class InitStructBuilder(object):
|
||||
|
||||
SIZE_LONG = 0
|
||||
SIZE_WORD = 1
|
||||
SIZE_BYTE = 2
|
||||
|
||||
@ -6,7 +6,6 @@ from amitools.vamos.machine.opcodes import op_jmp
|
||||
|
||||
|
||||
class LibFuncs(object):
|
||||
|
||||
LVO_Open = 1
|
||||
LVO_Close = 2
|
||||
LVO_Expunge = 3
|
||||
|
||||
@ -5,6 +5,7 @@ from amitools.vamos.astructs import (
|
||||
ULONG,
|
||||
)
|
||||
|
||||
|
||||
# TagItem
|
||||
@AmigaStructDef
|
||||
class TagItemStruct(AmigaStruct):
|
||||
|
||||
@ -40,7 +40,7 @@ class LibBase:
|
||||
tag=tag,
|
||||
pos_size=pos_size,
|
||||
neg_size=neg_size,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ from amitools.vamos.astructs import AmigaClassDef
|
||||
|
||||
@AmigaClassDef
|
||||
class Resident(ResidentStruct):
|
||||
|
||||
RTC_MATCHWORD = 0x4AFC
|
||||
|
||||
@classmethod
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
|
||||
|
||||
# tag a parameter for full testing
|
||||
def tag_full(value):
|
||||
return pytest.param(value, marks=pytest.mark.full)
|
||||
|
||||
@ -29,6 +29,7 @@ def libnative_initres_init_test(buildlibnix):
|
||||
sp = init_addr - 4
|
||||
# load lib
|
||||
seglist, addr, size, end = load_lib(alloc, buildlibnix)
|
||||
|
||||
# setup init func
|
||||
def init_func(op, pc):
|
||||
assert cpu.r_reg(REG_A0) == seglist.get_baddr()
|
||||
@ -63,6 +64,7 @@ def libnative_initres_autoinit_test(buildlibnix):
|
||||
sp = init_addr - 4
|
||||
# load lib
|
||||
seglist, addr, size, end = load_lib(alloc, buildlibnix)
|
||||
|
||||
# setup init func
|
||||
def init_func(op, pc):
|
||||
assert cpu.r_reg(REG_A0) == seglist.get_baddr()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user