PS2SDK
PS2 Homebrew Libraries
commandline.c
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 #include "defs.h"
17 #include "iomanX.h"
18 #include "stdio.h"
19 #include "sysclib.h"
20 
21 #include "iopmgr.h"
22 
23 extern int shutdown();
24 
29 {
30  char name[9];
31  iop_library_t *libptr;
32 
33  printf("Registered Libraries:\n");
34  libptr = GetLoadcoreInternalData()->let_next;
35  while (libptr)
36  {
37  /* We only have a 8-char buffer for the name, so we need to convert it into a C
38  string just in case the name is 8 chars. */
39  memset(name, 0, sizeof(name));
40  memcpy(name, libptr->name, 8);
41  printf(" %-20s v%d.%d\n",name,
42  (libptr->version&0xff00)>>8,libptr->version&0xff);
43  libptr = libptr->prev;
44  }
45  printf("\n");
46 }
47 
48 
53 {
55  printf("Loaded Modules:\n");
57  while (info != 0)
58  {
59  printf(" %-40s v%d.%d (%d)\n",info->name,
60  (info->version&0xff00)>>8,(info->version&0xff),info->flags);
61  info = info->next;
62  }
63  printf("\n");
64 }
65 
70 {
72  iop_device_t **devinfo_table;
73  int i;
74 
75  if (!(info = smod_get_mod_by_name(IOPMGR_IOMAN_IDENT))) {
76  printf("Unable to find '%s's module info!\n",IOPMGR_IOMAN_IDENT);
77  return;
78  }
79 
80  /* Find the start of the device info array, in .bss. */
81  devinfo_table = (iop_device_t **)(info->text_start + info->text_size + info->data_size + 0x0c);
82 
83  printf("Known '%s' devices:\n",IOPMGR_IOMAN_IDENT);
84  /* The device info table had 16 entries, but some may be empty. Just look at all of them. */
85  for (i = 0; i < 16; i++) {
86  if (devinfo_table[i])
87  printf(" %-10s: %-27s v%d.%d type:%08X\n",
88  devinfo_table[i]->name, devinfo_table[i]->desc,
89  (devinfo_table[i]->version&0xff00)>>8,
90  (devinfo_table[i]->version&0xff),
91  devinfo_table[i]->type);
92  }
93  printf("\n");
94 }
95 
100 {
102  iop_device_t **devinfo_table;
103  int i;
104 
105  if (!(info = smod_get_mod_by_name(IOPMGR_IOMANX_IDENT))) {
106  printf("Unable to find '%s's module info!\n",IOPMGR_IOMANX_IDENT);
107  return;
108  }
109 
110  /* Find the start of the device info array, in .bss. */
111  devinfo_table = (iop_device_t **)(info->text_start + info->text_size + info->data_size + 0x00);
112 
113  printf("Known '%s' devices:\n",IOPMGR_IOMANX_IDENT);
114  /* The device info table had 32 entries, but some may be empty. Just look at all of them. */
115  for (i = 0; i < 32; i++) {
116  if (devinfo_table[i])
117  printf(" %-10s: %-28s v%d.%d type:%08X\n",
118  devinfo_table[i]->name, devinfo_table[i]->desc,
119  (devinfo_table[i]->version&0xff00)>>8,
120  (devinfo_table[i]->version&0xff),
121  devinfo_table[i]->type);
122  }
123  printf("\n");
124 }
125 
131 void list_fs_devices(int mgrtype)
132 {
133  int count;
134  int i;
135  char *bufptr;
136  char buffer[256];
137  bufptr = &buffer[0];
138 
139  count = iopmgr_get_devicelist(mgrtype,IOP_DT_FS,bufptr);
140  printf("filesystems found : %d\n",count);
141 
142  for (i=0;i<count;i++)
143  {
144  printf(" %02d : %-10s - ",i,bufptr);
145  switch(iopmgr_get_devicetype(bufptr))
146  {
147  case IOPMGR_DEVTYPE_IOMAN: printf("%s\n",IOPMGR_IOMAN_IDENT);break;
148  case IOPMGR_DEVTYPE_IOMANX: printf("%s\n",IOPMGR_IOMANX_IDENT);break;
149  default: printf("Invalid\n");break;
150  }
151  bufptr += strlen(bufptr)+1;
152  }
153 }
154 
155 
161 void cmdline_handle(char *command, char *arg1)
162 {
163  if (!strcmp("modlist",command))
165  else if (!strcmp("iomanx",command))
166  {
168  list_fs_devices(IOPMGR_DEVTYPE_IOMANX);
169  }
170  else if (!strcmp("ioman",command))
171  {
173  list_fs_devices(IOPMGR_DEVTYPE_IOMAN);
174  }
175  else if (!strcmp("devices",command))
176  {
179  list_fs_devices(IOPMGR_DEVTYPE_ALL);
180  }
181  else if (!strcmp("libs",command))
183  else if (!strcmp("release",command))
184  shutdown();
185  else if (!strcmp("help",command))
186  {
187  printf("\nCommands are:\n modlist - List of Loaded Modules\n iomanx - List iomanx Devices\n ioman - List ioman Devices\n devices - List all Devices\n libs - List Registered Libraries\n release - release iopmgr lib if loaded\n help - This page\n");
188  }
189  else if (!strcmp("unreg",command))
190  {
191  if (arg1 != 0)
192  {
193  printf("unregistering : '%s' - ",arg1);
194  switch(slib_release_library(arg1))
195  {
196  case 0: printf("UnRegistered\n"); break;
197  case -1: printf("Failed to UnRegister\n"); break;
198  case -2: printf("Library Not Present\n"); break;
199  }
200  }
201  else printf("\nNo Library Specified\n");
202  }
203  else printf("\nUnknown Command , try 'help'\n");
204 }
iomanX.h
iopmgr.h
iopmgr_get_devicelist
int iopmgr_get_devicelist(int man, int devtype, char *buffer)
Definition: devices.c:102
sysclib.h
iopmgr_get_devicetype
int iopmgr_get_devicetype(char *device)
Definition: devices.c:184
smod_get_mod_by_name
int smod_get_mod_by_name(const char *name, smod_mod_info_t *info)
Definition: smod.c:54
s_info
Definition: xprintf.c:78
shutdown
int shutdown()
Definition: ioptrap.c:293
list_devices_ioman
void list_devices_ioman()
Definition: commandline.c:69
_iop_library
Definition: loadcore.h:68
list_all_libraries
void list_all_libraries()
Definition: commandline.c:28
count
u32 count
start sector of fragmented bd/file
Definition: usbhdfsd-common.h:3
list_fs_devices
void list_fs_devices(int mgrtype)
Definition: commandline.c:131
cmdline_handle
void cmdline_handle(char *command, char *arg1)
Definition: commandline.c:161
list_devices_iomanx
void list_devices_iomanx()
Definition: commandline.c:99
stdio.h
slib_release_library
int slib_release_library(const char *name)
Definition: slib.c:103
list_all_modules
void list_all_modules()
Definition: commandline.c:52
defs.h
_iop_device
Definition: ioman.h:64
_ModuleInfo
Definition: loadcore.h:31
version
unsigned int version
Definition: fileXio.h:5
smod_get_next_mod
int smod_get_next_mod(smod_mod_info_t *cur_mod, smod_mod_info_t *next_mod)
Definition: smod.c:30