* Memory location handled specially by a hw element
*/
-cl_memloc::cl_memloc(long addr):
+cl_memloc::cl_memloc(t_addr addr):
cl_base()
{
address= addr;
}
void
-cl_memloc::write(class cl_mem *mem, long addr, ulong *val)
+cl_memloc::write(class cl_mem *mem, t_addr addr, t_mem *val)
{
class cl_hw *hw;
int i;
cl_memloc_coll::cl_memloc_coll(void):
cl_sorted_list(2, 2)
{
- Duplicates= FALSE;
+ Duplicates= DD_FALSE;
}
void *
}
class cl_memloc *
-cl_memloc_coll::get_loc(long address)
+cl_memloc_coll::get_loc(t_addr address)
{
t_index i;
}
+/*
+ */
+
+cl_cell::cl_cell(int awidth):
+ cl_base()
+{
+ data= 0;
+ mask= 1;
+ for (; awidth; awidth--)
+ {
+ mask<<= 1;
+ mask|= 1;
+ }
+}
+
+/*t_mem
+cl_cell::read(void)
+{
+ return(data);
+}*/
+
+/*t_mem
+cl_cell::get(void)
+{
+ return(data);
+}*/
+
+/*void
+cl_cell::write(t_mem *val)
+{
+ data= *val= (*val & mask);
+}*/
+
+/*void
+cl_cell::set(t_mem val)
+{
+ data= val & mask;
+}*/
+
+
+cl_registered_cell::cl_registered_cell(int awidth):
+ cl_cell(awidth)
+{
+ hws= new cl_list(1, 1);
+ hardwares= 0;
+ nuof_hws= 0;
+}
+
+cl_registered_cell::~cl_registered_cell(void)
+{
+ hws->disconn_all();
+ delete hws;
+}
+
+t_mem
+cl_registered_cell::read(void)
+{
+ int i;
+
+ /*if (hws->count)
+ for (i= 0; i < hws->count; i++)
+ {
+ class cl_hw *hw= (class cl_hw *)(hws->at(i));
+ ;
+ }*/
+ if (nuof_hws)
+ for (i= 0; i < nuof_hws; i++)
+ {
+ //hardwares[i];
+ ;
+ }
+ return(data);
+}
+
+void
+cl_registered_cell::write(t_mem *val)
+{
+ int i;
+
+ /*if (hws->count)
+ for (i= 0; i < hws->count; i++)
+ {
+ class cl_hw *hw= (class cl_hw *)(hws->at(i));
+ ;
+ }*/
+ if (nuof_hws)
+ for (i= 0; i < nuof_hws; i++)
+ {
+ //hardwares[i];
+ ;
+ }
+ data= *val= (*val & mask);
+}
+
+
+/*
+ */
+
+cl_m::cl_m(t_addr asize, int awidth):
+ cl_mem(MEM_SFR, "sfr", 0, awidth)
+{
+ t_addr a;
+
+ size= asize;
+ width= awidth;
+ array= (class cl_cell **)malloc(size * sizeof(class cl_cell *));
+ for (a= 0; a < size; a++)
+ array[a]= new cl_registered_cell(width);
+}
+
+cl_m::~cl_m(void)
+{
+ t_addr a;
+
+ for (a= 0; a < size; a++)
+ delete array[a];
+ free(array);
+}
+
+t_mem
+cl_m::read(t_addr addr)
+{
+ if (addr >= size)
+ return(0);
+ return(array[addr]->read());
+}
+
+t_mem
+cl_m::get(t_addr addr)
+{
+ if (addr >= size)
+ return(0);
+ return(array[addr]->get());
+}
+
+void
+cl_m::write(t_addr addr, t_mem *val)
+{
+ if (addr >= size)
+ return;
+ array[addr]->write(val);
+}
+
+void
+cl_m::set(t_addr addr, t_mem val)
+{
+ if (addr >= size)
+ return;
+ array[addr]->set(val);
+}
+
+
/*
* Memory
******************************************************************************
*/
-cl_mem::cl_mem(enum mem_class atype, t_addr asize, int awidth):
- cl_base()
+cl_mem::cl_mem(enum mem_class atype, char *aclass_name,
+ t_addr asize, int awidth):
+ cl_guiobj()
{
int i;
type= atype;
+ class_name= aclass_name;
width= awidth;
size= asize;
mem= 0;
read_locs= new cl_memloc_coll();
write_locs= new cl_memloc_coll();
dump_finished= 0;
+ addr_format= (char *)malloc(10);
+ sprintf(addr_format, "0x%%0%dx",
+ size-1<=0xf?1:
+ (size-1<=0xff?2:
+ (size-1<=0xfff?3:
+ (size-1<=0xffff?4:
+ (size-1<=0xfffff?5:
+ (size-1<=0xffffff?6:12))))));
+ data_format= (char *)malloc(10);
+ sprintf(data_format, "%%0%dx", width/4+((width%4)?1:0));
}
cl_mem::~cl_mem(void)
{
if (mem)
free(mem);
+ if (addr_format)
+ free(addr_format);
+ if (data_format)
+ free(data_format);
delete read_locs;
delete write_locs;
}
return(s?s:(char*)"NONE");
}
-ulong
+t_mem
cl_mem::read(t_addr addr)
{
class cl_memloc *loc;
return((((TYPE_UDWORD*)mem)[addr])&mask);
}
-ulong
+t_mem
cl_mem::get(t_addr addr)
{
if (addr >= size)
((TYPE_UDWORD*)mem)[addr]&= ~bits;
}
-void
+t_mem
+cl_mem::add(t_addr addr, long what)
+{
+ if (addr >= size)
+ return(0);
+ if (width <= 8)
+ {
+ ((TYPE_UBYTE*)mem)[addr]= ((TYPE_UBYTE*)mem)[addr] + what;
+ return(((TYPE_UBYTE*)mem)[addr]);
+ }
+ else if (width <= 16)
+ {
+ ((TYPE_UWORD*)mem)[addr]= ((TYPE_UWORD*)mem)[addr] + what;
+ return(((TYPE_UWORD*)mem)[addr]);
+ }
+ else
+ {
+ ((TYPE_UDWORD*)mem)[addr]= ((TYPE_UDWORD*)mem)[addr] + what;
+ return(((TYPE_UDWORD*)mem)[addr]);
+ }
+}
+
+t_addr
cl_mem::dump(t_addr start, t_addr stop, int bpl, class cl_console *con)
{
int i;
- if (start < 0)
- {
- start= dump_finished;
- stop= start+stop;
- }
while ((start <= stop) &&
(start < size))
{
- con->printf("%06x ", start);
- for (i= 0; (i < bpl) &&
+ con->dd_printf(addr_format, start); con->dd_printf(" ");
+ for (i= 0;
+ (i < bpl) &&
(start+i < size) &&
(start+i <= stop);
i++)
{
- char format[10];
- sprintf(format, "%%0%dx ", width/4);
- con->printf(format/*"%02x "*/, get(start+i));
+ con->dd_printf(data_format, read(start+i)); con->dd_printf(" ");
}
while (i < bpl)
{
- //FIXME
- con->printf(" ");
+ int j;
+ j= width/4 + ((width%4)?1:0) + 1;
+ while (j)
+ {
+ con->dd_printf(" ");
+ j--;
+ }
i++;
}
for (i= 0; (i < bpl) &&
i++)
{
long c= get(start+i);
- con->printf("%c", isprint(255&c)?(255&c):'.');
+ con->dd_printf("%c", isprint(255&c)?(255&c):'.');
if (width > 8)
- con->printf("%c", isprint(255&(c>>8))?(255&(c>>8)):'.');
+ con->dd_printf("%c", isprint(255&(c>>8))?(255&(c>>8)):'.');
if (width > 16)
- con->printf("%c", isprint(255&(c>>16))?(255&(c>>16)):'.');
+ con->dd_printf("%c", isprint(255&(c>>16))?(255&(c>>16)):'.');
if (width > 24)
- con->printf("%c", isprint(255&(c>>24))?(255&(c>>24)):'.');
+ con->dd_printf("%c", isprint(255&(c>>24))?(255&(c>>24)):'.');
}
- con->printf("\n");
+ con->dd_printf("\n");
dump_finished= start+i;
start+= bpl;
}
+ return(dump_finished);
+}
+
+t_addr
+cl_mem::dump(class cl_console *con)
+{
+ return(dump(dump_finished, dump_finished+10*8-1, 8, con));
+}
+
+bool
+cl_mem::search_next(bool case_sensitive, t_mem *array, int len, t_addr *addr)
+{
+ t_addr a;
+ int i;
+ bool found;
+
+ if (addr == NULL)
+ a= 0;
+ else
+ a= *addr;
+
+ if (a+len > size)
+ return(DD_FALSE);
+
+ found= DD_FALSE;
+ while (!found &&
+ a+len <= size)
+ {
+ bool match= DD_TRUE;
+ for (i= 0; i < len && match; i++)
+ {
+ t_mem d1, d2;
+ d1= get(a+i);
+ d2= array[i];
+ if (!case_sensitive)
+ {
+ if (/*d1 < 128*/isalpha(d1))
+ d1= toupper(d1);
+ if (/*d2 < 128*/isalpha(d2))
+ d2= toupper(d2);
+ }
+ match= d1 == d2;
+ }
+ found= match;
+ if (!found)
+ a++;
+ }
+
+ if (addr)
+ *addr= a;
+ return(found);
}
* Bitmap
*/
-cl_bitmap::cl_bitmap(long asize):
+cl_bitmap::cl_bitmap(t_addr asize):
cl_base()
{
map= (uchar*)malloc(size= asize/(8*SIZEOF_CHAR));
}
void
-cl_bitmap::set(long pos)
+cl_bitmap::set(t_addr pos)
{
int i;
}
void
-cl_bitmap::clear(long pos)
+cl_bitmap::clear(t_addr pos)
{
int i;
}
bool
-cl_bitmap::get(long pos)
+cl_bitmap::get(t_addr pos)
{
return(map[pos/(8*SIZEOF_CHAR)] & (1 << (pos & ((8*SIZEOF_CHAR)-1))));
}
* Special memory for code (ROM)
*/
-cl_rom::cl_rom(long asize, int awidth):
- cl_mem(MEM_ROM, asize, awidth)
+cl_rom::cl_rom(t_addr asize, int awidth):
+ cl_mem(MEM_ROM, get_id_string(mem_classes, MEM_ROM), asize, awidth)
{
bp_map= new cl_bitmap(asize);
inst_map= new cl_bitmap(asize);