#include "types.h"
#include "ctype.h"
#include "asm/processor.h"
+#include "errors.h"
#define READ_BLOCKS_USE_READ 1
if (prom_args.args[2+nargs] != 0)
{
- prom_printf ("method '%s' failed %d\n", method, prom_args.args[2+nargs]);
+ prom_printf ("method '%s' failed %p\n", method, prom_args.args[2+nargs]);
return 0;
}
return prom_args.args[2+nargs+1];
return prom_getprop (prom_options, name, mem, len);
}
+int
+prom_get_devtype (char *device)
+{
+ phandle dev;
+ int result;
+ char tmp[64];
+
+ /* Find OF device phandle */
+ dev = prom_finddevice(device);
+ if (dev == PROM_INVALID_HANDLE) {
+ return FILE_ERR_BADDEV;
+ }
+
+ /* Check the kind of device */
+ result = prom_getprop(dev, "device_type", tmp, 63);
+ if (result == -1) {
+ prom_printf("can't get <device_type> for device: %s\n", device);
+ return FILE_ERR_BADDEV;
+ }
+ tmp[result] = 0;
+ if (!strcmp(tmp, "block"))
+ return FILE_DEVICE_BLOCK;
+ else if (!strcmp(tmp, "network"))
+ return FILE_DEVICE_NET;
+ else {
+ prom_printf("Unkown device type <%s>\n", tmp);
+ return FILE_ERR_BADDEV;
+ }
+}
+
void
prom_init (prom_entry pp)
{
void
prom_vfprintf (prom_handle file, char *fmt, va_list ap)
{
- static char printf_buf[1024];
+ static char printf_buf[1536];
vsprintf (printf_buf, fmt, ap);
prom_puts (file, printf_buf);
}
void
prom_vprintf (char *fmt, va_list ap)
{
- static char printf_buf[1024];
+ static char printf_buf[1536];
vsprintf (printf_buf, fmt, ap);
prom_puts (prom_stdout, printf_buf);
}
va_end (ap);
}
+void
+prom_perror (int error, char *filename)
+{
+ if (error == FILE_ERR_EOF)
+ prom_printf("%s: Unexpected End Of File\n", filename);
+ else if (error == FILE_ERR_NOTFOUND)
+ prom_printf("%s: No such file or directory\n", filename);
+ else if (error == FILE_CANT_SEEK)
+ prom_printf("%s: Seek error\n", filename);
+ else if (error == FILE_IOERR)
+ prom_printf("%s: Input/output error\n", filename);
+ else if (error == FILE_BAD_PATH)
+ prom_printf("%s: Path too long\n", filename);
+ else if (error == FILE_ERR_BAD_TYPE)
+ prom_printf("%s: Not a regular file\n", filename);
+ else if (error == FILE_ERR_NOTDIR)
+ prom_printf("%s: Not a directory\n", filename);
+ else if (error == FILE_ERR_BAD_FSYS)
+ prom_printf("%s: Unknown or corrupt filesystem\n", filename);
+ else if (error == FILE_ERR_SYMLINK_LOOP)
+ prom_printf("%s: Too many levels of symbolic links\n", filename);
+ else if (error == FILE_ERR_LENGTH)
+ prom_printf("%s: File too large\n", filename);
+ else if (error == FILE_ERR_FSBUSY)
+ prom_printf("%s: Filesystem busy\n", filename);
+ else if (error == FILE_ERR_BADDEV)
+ prom_printf("%s: Unable to open file, Invalid device\n", filename);
+ else
+ prom_printf("%s: Unknown error\n", filename);
+}
+
void
prom_readline (char *prompt, char *buf, int len)
{
prom_exit ();
}
+void
+prom_sleep (int seconds)
+{
+ int end;
+ end = (prom_getms() + (seconds * 1000));
+ while (prom_getms() <= end);
+}
+
void *
prom_claim (void *virt, unsigned int size, unsigned int align)
{