summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c144
1 files changed, 64 insertions, 80 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 2b4bab9b46..9d2866fcf3 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -87,6 +87,36 @@
87#include "ds2411.h" 87#include "ds2411.h"
88#endif 88#endif
89 89
90static bool dbg_list(char *title, int count, int selection_size,
91 int (*action_callback)(int btn, struct gui_synclist *lists),
92 char* (*dbg_getname)(int item, void * data, char *buffer))
93{
94 struct gui_synclist lists;
95 int action;
96
97 gui_synclist_init(&lists, dbg_getname, NULL, false, selection_size);
98 gui_synclist_set_title(&lists, title, NOICON);
99 gui_synclist_set_icon_callback(&lists, NULL);
100 gui_synclist_set_nb_items(&lists, count);
101 action_signalscreenchange();
102 gui_synclist_draw(&lists);
103 while(1)
104 {
105 gui_syncstatusbar_draw(&statusbars, true);
106 action = get_action(CONTEXT_STD, HZ/5);
107 if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD))
108 gui_synclist_draw(&lists);
109 if (action_callback)
110 action = action_callback(action, &lists);
111 if (action == ACTION_STD_CANCEL)
112 break;
113 else if(default_event_handler(action) == SYS_USB_CONNECTED)
114 return true;
115 }
116 action_signalscreenchange();
117 return false;
118}
119
90/*---------------------------------------------------*/ 120/*---------------------------------------------------*/
91/* SPECIAL DEBUG STUFF */ 121/* SPECIAL DEBUG STUFF */
92/*---------------------------------------------------*/ 122/*---------------------------------------------------*/
@@ -94,6 +124,7 @@ extern int ata_device;
94extern int ata_io_address; 124extern int ata_io_address;
95extern struct thread_entry threads[MAXTHREADS]; 125extern struct thread_entry threads[MAXTHREADS];
96 126
127
97#ifndef SIMULATOR 128#ifndef SIMULATOR
98static char thread_status_char(int status) 129static char thread_status_char(int status)
99{ 130{
@@ -112,7 +143,7 @@ static char thread_status_char(int status)
112#else 143#else
113#define IF_COP2(...) 144#define IF_COP2(...)
114#endif 145#endif
115static char* dbg_os_getname(int selected_item, void * data, char *buffer) 146static char* threads_getname(int selected_item, void * data, char *buffer)
116{ 147{
117 (void)data; 148 (void)data;
118 struct thread_entry *thread = NULL; 149 struct thread_entry *thread = NULL;
@@ -145,41 +176,24 @@ static char* dbg_os_getname(int selected_item, void * data, char *buffer)
145#endif 176#endif
146 return buffer; 177 return buffer;
147} 178}
148 179static int dbg_threads_action_callback(int action, struct gui_synclist *lists)
149/* Test code!!! */
150static bool dbg_os(void)
151{ 180{
152 struct gui_synclist lists;
153 int action;
154
155 gui_synclist_init(&lists, dbg_os_getname, NULL, false, 1);
156 gui_synclist_set_title(&lists, IF_COP2("Core and ") "Stack usage:", NOICON);
157 gui_synclist_set_icon_callback(&lists, NULL);
158 gui_synclist_set_nb_items(&lists, MAXTHREADS);
159 action_signalscreenchange();
160 while(1)
161 {
162 /* Do a redraw every time so the thread info is updated,
163 disabled scrolling, but the name isnt important */
164 gui_synclist_draw(&lists);
165 gui_syncstatusbar_draw(&statusbars, true);
166 action = get_action(CONTEXT_STD, HZ/5);
167 gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD);
168 if (action == ACTION_STD_CANCEL)
169 break;
170#ifdef ROCKBOX_HAS_LOGF 181#ifdef ROCKBOX_HAS_LOGF
171 else if (action == ACTION_STD_OK) 182 if (action == ACTION_STD_OK)
172 { 183 {
173 struct thread_entry *thread = &threads[gui_synclist_get_sel_pos(&lists)]; 184 struct thread_entry *thread = &threads[gui_synclist_get_sel_pos(lists)];
174 if (thread->name != NULL) 185 if (thread->name != NULL)
175 remove_thread(thread); 186 remove_thread(thread);
176 }
177#endif
178 else if(default_event_handler(action) == SYS_USB_CONNECTED)
179 return true;
180 } 187 }
181 action_signalscreenchange(); 188#endif
182 return false; 189 gui_synclist_draw(lists);
190 return action;
191}
192/* Test code!!! */
193static bool dbg_os(void)
194{
195 return dbg_list(IF_COP2("Core and ") "Stack usage:", MAXTHREADS, 1,
196 dbg_threads_action_callback, threads_getname);
183} 197}
184#endif /* !SIMULATOR */ 198#endif /* !SIMULATOR */
185 199
@@ -682,56 +696,26 @@ static bool dbg_hw_info(void)
682#endif /* !SIMULATOR */ 696#endif /* !SIMULATOR */
683 697
684#ifndef SIMULATOR 698#ifndef SIMULATOR
685bool dbg_partitions(void) 699static char* dbg_partitions_getname(int selected_item, void * data, char *buffer)
686{ 700{
687 int partition=0; 701 (void)data;
688 702 int partition = selected_item/2;
689 lcd_clear_display(); 703 struct partinfo* p = disk_partinfo(partition);
690 lcd_puts(0, 0, "Partition"); 704 if (selected_item%2)
691 lcd_puts(0, 1, "list");
692 lcd_update();
693 sleep(HZ/2);
694
695 while(1)
696 { 705 {
697 char buf[32]; 706 snprintf(buffer, MAX_PATH, "T:%x %ld MB", p->type, p->size / 2048);
698 int button;
699 struct partinfo* p = disk_partinfo(partition);
700
701 lcd_clear_display();
702 snprintf(buf, sizeof buf, "P%d: S:%lx", partition, p->start);
703 lcd_puts(0, 0, buf);
704 snprintf(buf, sizeof buf, "T:%x %ld MB", p->type, p->size / 2048);
705 lcd_puts(0, 1, buf);
706 lcd_update();
707
708 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK);
709
710 switch(button)
711 {
712 case ACTION_STD_CANCEL:
713 action_signalscreenchange();
714 return false;
715
716 case ACTION_SETTINGS_DEC:
717 partition--;
718 if (partition < 0)
719 partition = 3;
720 break;
721
722 case ACTION_SETTINGS_INC:
723 partition++;
724 if (partition > 3)
725 partition = 0;
726 break;
727
728 default:
729 if(default_event_handler(button) == SYS_USB_CONNECTED)
730 return true;
731 break;
732 }
733 } 707 }
734 return false; 708 else
709 {
710 snprintf(buffer, MAX_PATH, "P%d: S:%lx", partition, p->start);
711 }
712 return buffer;
713}
714
715bool dbg_partitions(void)
716{
717 return dbg_list("Partition Info", 4, 2,
718 NULL, dbg_partitions_getname);
735} 719}
736#endif 720#endif
737 721