11 static void printbits( char *out, int nbits, uint32_t value )
15 for( i=32; i>nbits; i-- ) {
16 if( !(i % 8) ) *out++ = ' ';
21 *out++ = (value&(1<<--nbits) ? '1' : '0');
22 if( !(nbits % 8) ) *out++ = ' ';
27 static void printhex( char *out, int nbits, uint32_t value )
29 char tmp[10], *p = tmp;
32 sprintf( tmp, "%08X", value );
33 for( i=32; i>0; i-=4, p++ ) {
34 if( i <= nbits ) *out++ = *p;
41 static GtkCList *create_mmr_page( char *name )
47 scroll = gtk_scrolled_window_new(NULL, NULL);
48 gtk_widget_show( scroll );
49 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scroll),
50 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS );
51 list = GTK_CLIST(gtk_clist_new(5));
52 gtk_clist_set_column_width(list, 0, 60);
53 gtk_clist_set_column_width(list, 1, 50);
54 gtk_clist_set_column_width(list, 2, 60);
55 gtk_clist_set_column_width(list, 3, 220);
56 gtk_clist_set_column_width(list, 4, 160);
57 gtk_clist_set_column_justification(list, 0, GTK_JUSTIFY_CENTER );
58 gtk_clist_set_column_justification(list, 2, GTK_JUSTIFY_CENTER );
59 gtk_clist_set_column_justification(list, 3, GTK_JUSTIFY_CENTER );
60 gtk_clist_set_column_title(list, 0, "Address");
61 gtk_clist_set_column_title(list, 1, "Register");
62 gtk_clist_set_column_title(list, 2, "Value");
63 gtk_clist_set_column_title(list, 3, "Bit Pattern");
64 gtk_clist_set_column_title(list, 4, "Description");
65 gtk_clist_column_titles_show(list);
66 gtk_widget_modify_font( GTK_WIDGET(list), fixed_list_font );
67 gtk_widget_show( GTK_WIDGET(list) );
68 tab = gtk_label_new(_(name));
69 gtk_widget_show( tab );
70 gtk_container_add( GTK_CONTAINER(scroll), GTK_WIDGET(list) );
71 gtk_notebook_append_page( mmr_book, scroll, tab );
72 gtk_object_set_data( GTK_OBJECT(mmr_win), name, list );
76 void update_mmr_win( void )
79 GtkCList *page, *all_page;
80 char data[10], bits[40];
82 all_page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmr_win), "All" ));
84 for( i=1; i < num_io_rgns; i++ ) {
85 page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmr_win),
87 for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {
88 if( *io_rgn[i]->ports[j].val !=
89 *(uint32_t *)(io_rgn[i]->save_mem+io_rgn[i]->ports[j].offset)){
90 int sz = io_rgn[i]->ports[j].width;
92 printhex( data, sz, *io_rgn[i]->ports[j].val );
93 printbits( bits, sz, *io_rgn[i]->ports[j].val );
95 gtk_clist_set_text( page, j, 2, data );
96 gtk_clist_set_text( page, j, 3, bits );
97 gtk_clist_set_foreground( page, j, &clrChanged );
99 gtk_clist_set_text( all_page, count, 2, data );
100 gtk_clist_set_text( all_page, count, 3, bits );
101 gtk_clist_set_foreground( all_page, count, &clrChanged );
104 gtk_clist_set_foreground( page, j, &clrNormal );
105 gtk_clist_set_foreground( all_page, count, &clrNormal );
109 memcpy( io_rgn[i]->save_mem, io_rgn[i]->mem, PAGE_SIZE );
113 void init_mmr_win( void )
117 mmr_win = create_mmr_win();
118 mmr_book = GTK_NOTEBOOK( gtk_object_get_data( GTK_OBJECT(mmr_win), "mmr_notebook" ));
120 /* kill the dummy page glade insists on adding */
121 gtk_notebook_remove_page( mmr_book, 0 );
123 all_list = create_mmr_page( "All" );
124 for( i=1; i < num_io_rgns; i++ ) {
125 GtkCList *list = create_mmr_page( io_rgn[i]->id );
127 for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {
128 int sz = io_rgn[i]->ports[j].width;
129 char addr[10], data[10], bits[40];
130 char *arr[] = { addr, io_rgn[i]->ports[j].id, data, bits,
131 io_rgn[i]->ports[j].desc };
132 sprintf( addr, "%08X",
133 io_rgn[i]->base + io_rgn[i]->ports[j].offset );
134 printhex( data, sz, *io_rgn[i]->ports[j].val );
135 printbits( bits, io_rgn[i]->ports[j].width,
136 *io_rgn[i]->ports[j].val );
137 gtk_clist_append( list, arr );
138 gtk_clist_append( all_list, arr );
143 void mmr_open_win( void )
145 gtk_widget_show( mmr_win );
148 void mmr_close_win( void )
150 gtk_widget_hide( mmr_win );
.