50 #include <sys/types.h> 76 static void readstr(
struct cpu *
cpu, uint64_t
addr,
char *strbuf,
80 for (i=0; i<bufsize; i++) {
85 if (ch >= 1 && ch < 32)
88 if (strbuf[i] ==
'\0')
92 strbuf[bufsize - 1] =
'\0';
102 static void of_store_32bit_in_host(
unsigned char *d, uint32_t x)
104 d[0] = x >> 24; d[1] = x >> 16;
105 d[2] = x >> 8; d[3] = x;
114 static int find_device_handle(
struct of_data *ofd,
const char *name)
116 int handle = 1, cur_parent = 1;
122 struct of_device *od = ofd->of_devices;
126 while (name[0] ==
'/')
130 snprintf(tmp,
sizeof(tmp),
"%s", name);
132 while (tmp[i] !=
'\0' && tmp[i] !=
'/')
136 OF_FIND(od, strcmp(od->name, tmp) == 0 &&
137 od->parent == cur_parent);
141 handle = cur_parent = od->handle;
154 fatal(
"[ of: call_method_2_2('%s'): TODO ]\n", arg[0]);
161 fatal(
"[ of: call_method_3_4('%s'): TODO ]\n", arg[0]);
168 if (strcmp(arg[0],
"set-colors") == 0) {
171 int color = OF_GET_ARG(3);
172 uint64_t ptr = OF_GET_ARG(4);
173 unsigned char rgb[3];
183 fatal(
"[ of: call_method_5_2('%s'): TODO ]\n", arg[0]);
192 fatal(
"[ of: call_method_6_1('%s'): TODO ]\n", arg[0]);
199 fatal(
"[ of: call_method_6_2('%s'): TODO ]\n", arg[0]);
207 int handle = OF_GET_ARG(0);
208 OF_FIND(od, od->parent == handle);
220 fatal(
"[ of: claim(0x%x,0x%x,0x%x): TODO ]\n",
221 OF_GET_ARG(0), OF_GET_ARG(1), OF_GET_ARG(2));
246 struct of_device_property *pr;
247 int handle = OF_GET_ARG(0), i, len_returned = 0;
248 uint64_t buf = OF_GET_ARG(2);
249 uint64_t max = OF_GET_ARG(3);
251 OF_FIND(od, od->handle == handle);
253 fatal(
"[ of: WARNING: getprop handle=%i; no such handle ]\n",
259 OF_FIND(pr, strcmp(pr->name, arg[1]) == 0);
261 fatal(
"[ of: WARNING: getprop: no property '%s' at handle" 262 " %i (device '%s') ]\n", arg[1], handle, od->name);
266 if (pr->data == NULL) {
267 fatal(
"[ of: WARNING: property '%s' of '%s' has no data! ]\n",
273 len_returned = pr->len <= max? pr->len : max;
275 for (i=0; i<len_returned; i++) {
278 fatal(
"[ of: getprop memory_rw() error ]\n");
292 struct of_device_property *pr;
293 int handle = OF_GET_ARG(0);
295 OF_FIND(od, od->handle == handle);
297 fatal(
"[ of: TODO: getproplen handle=%i; no such handle ]\n",
303 OF_FIND(pr, strcmp(pr->name, arg[1]) == 0);
305 fatal(
"[ of: TODO: getproplen: no property '%s' at handle" 306 " %i (device '%s') ]\n", arg[1], handle, od->name);
317 int handle = OF_GET_ARG(0);
326 if (strcmp(arg[0],
"#lines 2 - to line#") == 0) {
328 fatal(
"[ of: interpret_1('%s'): TODO ]\n", arg[0]);
338 if (strcmp(arg[0],
"#columns") == 0) {
340 }
else if (strcmp(arg[0],
"#lines") == 0) {
342 }
else if (strcmp(arg[0],
"char-height") == 0) {
344 }
else if (strcmp(arg[0],
"char-width") == 0) {
346 }
else if (strcmp(arg[0],
"line#") == 0) {
348 }
else if (strcmp(arg[0],
"font-adr") == 0) {
351 fatal(
"[ of: interpret_2('%s'): TODO ]\n", arg[0]);
360 fatal(
"[ of: package-to-path: TODO ]\n");
368 int handle = OF_GET_ARG(0);
369 OF_FIND(od, od->handle == handle);
378 int handle = OF_GET_ARG(0), parent = 0, peer = 0, seen_self = 1;
386 OF_FIND(od, od->handle == handle);
388 fatal(
"[ of: TODO: peer(): can't find handle %i ]\n", handle);
397 if (od->parent == parent) {
402 if (od->handle == handle)
415 uint64_t ptr = OF_GET_ARG(0);
424 fatal(
"[ of: TODO: write: memory_rw() error ]\n");
436 cout <<
"Unimplemented OF_SERVICE(open) with name: '" << s <<
"'\n";
447 uint64_t ptr = OF_GET_ARG(1);
459 fatal(
"[ of: TODO: read: memory_rw() error ]\n");
464 return c == -1? -1 : 0;
471 uint64_t ptr = OF_GET_ARG(1);
472 int n_written = 0, i, len = OF_GET_ARG(2);
476 for (i=0; i<len; i++) {
480 fatal(
"[ of: TODO: write: memory_rw() error ]\n");
501 static int of_get_unused_device_handle(
struct of_data *of_data)
504 struct of_device *od = of_data->of_devices;
507 if (od->handle > max_handle)
508 max_handle = od->handle;
512 return max_handle + 1;
521 static struct of_device *of_add_device(
struct of_data *of_data,
const char *name,
522 const char *parentname)
524 struct of_device *od;
526 CHECK_ALLOCATION(od = (
struct of_device *) malloc(
sizeof(
struct of_device)));
527 memset(od, 0,
sizeof(
struct of_device));
531 od->handle = of_get_unused_device_handle(of_data);
532 od->parent = find_device_handle(of_data, parentname);
533 if (od->parent < 0) {
534 fatal(
"of_add_device(): adding '%s' to parent '%s' failed: " 535 "parent not found!\n", name, parentname);
539 od->next = of_data->of_devices;
540 of_data->of_devices = od;
551 static void of_add_prop(
struct of_data *of_data,
const char *devname,
552 const char *propname,
unsigned char *
data, uint32_t len,
int flags)
554 struct of_device_property *pr;
555 struct of_device *od = of_data->of_devices;
556 int h = find_device_handle(of_data, devname);
558 CHECK_ALLOCATION(pr = (
struct of_device_property *) malloc(
sizeof(
struct of_device_property)));
559 memset(pr, 0,
sizeof(
struct of_device_property));
561 OF_FIND(od, od->handle == h);
563 fatal(
"of_add_prop(): device '%s' not registered\n", devname);
572 pr->next = od->properties;
582 static void of_add_service(
struct of_data *of_data,
const char *name,
583 int (*
f)(OF_SERVICE_ARGS),
int n_args,
int n_ret_args)
585 struct of_service *os;
587 CHECK_ALLOCATION(os = (
struct of_service *) malloc(
sizeof(
struct of_service)));
588 memset(os, 0,
sizeof(
struct of_service));
594 os->n_ret_args = n_ret_args;
596 os->next = of_data->of_services;
597 of_data->of_services = os;
606 static void of_dump_devices(
struct of_data *ofd,
int parent)
609 struct of_device *od = ofd->of_devices;
612 struct of_device_property *pr = od->properties;
613 if (od->parent != parent) {
618 debug(
"\"%s\"", od->name);
619 debug(
" (handle %i)\n", od->handle);
623 debug(
"(%s: ", pr->name);
624 if (pr->flags == OF_PROP_STRING)
625 debug(
"\"%s\"", pr->data);
627 debug(
"%i bytes", pr->len);
632 of_dump_devices(ofd, od->handle);
644 static void of_dump_all(
struct of_data *ofd)
647 struct of_service *os;
649 debug(
"openfirmware debug dump:\n");
653 of_dump_devices(ofd, 0);
656 os = ofd->of_services;
658 debug(
"service '%s'", os->name);
659 if (os->n_ret_args > 0 || os->n_args > 0) {
661 if (os->n_args > 0) {
662 debug(
"%i arg%s", os->n_args,
663 os->n_args > 1?
"s" :
"");
664 if (os->n_ret_args > 0)
667 if (os->n_ret_args > 0)
668 debug(
"%i return value%s", os->n_ret_args,
669 os->n_ret_args > 1?
"s" :
"");
685 static void of_add_prop_int32(
struct of_data *ofd,
686 const char *devname,
const char *propname, uint32_t x)
692 of_store_32bit_in_host(p, x);
693 of_add_prop(ofd, devname, propname, p,
sizeof(int32_t),
703 static void of_add_prop_str(
struct machine *
machine,
struct of_data *ofd,
704 const char *devname,
const char *propname,
const char *
data)
710 of_add_prop(ofd, devname, propname, (
unsigned char *)p,
strlen(p) + 1,
720 struct of_data *ofd = machine->
md.
of_data;
721 unsigned char *isa_ranges;
723 of_add_device(ofd,
"isa",
"/");
726 memset(isa_ranges, 0, 32);
730 of_store_32bit_in_host(isa_ranges + 0, 0);
731 of_store_32bit_in_host(isa_ranges + 4, 0xc0000000);
733 of_store_32bit_in_host(isa_ranges + 16, 1);
734 of_store_32bit_in_host(isa_ranges + 20, 0xd0000000);
736 of_add_prop(ofd,
"/isa",
"ranges", isa_ranges, 32, 0);
745 struct of_data *ofd = machine->
md.
of_data;
746 unsigned char *adb_interrupts, *adb_reg;
748 CHECK_ALLOCATION(adb_interrupts = (
unsigned char *) malloc(4 *
sizeof(uint32_t)));
751 of_add_device(ofd,
"adb",
"/bandit/gc");
752 of_add_prop_str(machine, ofd,
"/bandit/gc/adb",
"name",
"via-cuda");
753 of_store_32bit_in_host(adb_interrupts + 0, 25);
754 of_store_32bit_in_host(adb_interrupts + 4, 0);
755 of_store_32bit_in_host(adb_interrupts + 8, 0);
756 of_store_32bit_in_host(adb_interrupts + 12, 0);
757 of_add_prop(ofd,
"/bandit/gc/adb",
"interrupts", adb_interrupts,
758 4*
sizeof(uint32_t), 0);
759 of_store_32bit_in_host(adb_reg + 0, 0x16000);
760 of_store_32bit_in_host(adb_reg + 4, 0x2000);
761 of_store_32bit_in_host(adb_reg + 8, 0);
762 of_store_32bit_in_host(adb_reg + 12, 0);
763 of_store_32bit_in_host(adb_reg + 16, 0);
764 of_store_32bit_in_host(adb_reg + 20, 0);
765 of_store_32bit_in_host(adb_reg + 24, 0);
766 of_store_32bit_in_host(adb_reg + 28, 0);
767 of_add_prop(ofd,
"/bandit/gc/adb",
"reg", adb_reg,
768 8*
sizeof(uint32_t), 0);
777 struct of_data *ofd = machine->
md.
of_data;
778 unsigned char *zs_interrupts, *zs_reg;
783 of_add_device(ofd,
"zs",
"/bandit/gc");
784 of_add_prop_str(machine, ofd,
"/bandit/gc/zs",
"device_type",
"serial");
785 of_add_prop_str(machine, ofd,
"/bandit/gc/zs",
"name",
"escc");
786 of_store_32bit_in_host(zs_reg + 0, 0x13000);
787 of_store_32bit_in_host(zs_reg + 4, 0x40);
788 of_store_32bit_in_host(zs_reg + 8, 0x100);
789 of_store_32bit_in_host(zs_reg + 12, 0x100);
790 of_store_32bit_in_host(zs_reg + 16, 0x200);
791 of_store_32bit_in_host(zs_reg + 20, 0x100);
792 of_add_prop(ofd,
"/bandit/gc/zs",
"reg", zs_reg, 6*
sizeof(uint32_t), 0);
795 CHECK_ALLOCATION(zs_interrupts = (
unsigned char *) malloc(3 *
sizeof(uint32_t)));
798 of_add_device(ofd,
"zstty1",
"/bandit/gc/zs");
799 of_add_prop_str(machine, ofd,
"/bandit/gc/zs/zstty1",
"name",
"ch-a");
800 of_store_32bit_in_host(zs_interrupts + 0, 16);
801 of_store_32bit_in_host(zs_interrupts + 4, 0);
802 of_store_32bit_in_host(zs_interrupts + 8, 0);
803 of_add_prop(ofd,
"/bandit/gc/zs/zstty1",
"interrupts", zs_interrupts,
804 3*
sizeof(uint32_t), 0);
805 of_store_32bit_in_host(zs_reg + 0, 0x13800);
806 of_store_32bit_in_host(zs_reg + 4, 0x100);
807 of_store_32bit_in_host(zs_reg + 8, 0x100);
808 of_store_32bit_in_host(zs_reg + 12, 0x100);
809 of_store_32bit_in_host(zs_reg + 16, 0x200);
810 of_store_32bit_in_host(zs_reg + 20, 0x100);
811 of_add_prop(ofd,
"/bandit/gc/zs/zstty1",
812 "reg", zs_reg, 6*
sizeof(uint32_t), 0);
815 CHECK_ALLOCATION(zs_interrupts = (
unsigned char *) malloc(3 *
sizeof(uint32_t)));
818 of_add_device(ofd,
"zstty0",
"/bandit/gc/zs");
819 of_add_prop_str(machine, ofd,
"/bandit/gc/zs/zstty0",
"name",
"ch-b");
820 of_store_32bit_in_host(zs_interrupts + 0, 15);
821 of_store_32bit_in_host(zs_interrupts + 4, 0);
822 of_store_32bit_in_host(zs_interrupts + 8, 0);
823 of_add_prop(ofd,
"/bandit/gc/zs/zstty0",
"interrupts", zs_interrupts,
824 3*
sizeof(uint32_t), 0);
825 of_store_32bit_in_host(zs_reg + 0, 0x13400);
826 of_store_32bit_in_host(zs_reg + 4, 0x100);
827 of_store_32bit_in_host(zs_reg + 8, 0x100);
828 of_store_32bit_in_host(zs_reg + 12, 0x100);
829 of_store_32bit_in_host(zs_reg + 16, 0x200);
830 of_store_32bit_in_host(zs_reg + 20, 0x100);
831 of_add_prop(ofd,
"/bandit/gc/zs/zstty0",
832 "reg", zs_reg, 6*
sizeof(uint32_t), 0);
841 struct of_data *ofd = machine->
md.
of_data;
842 unsigned char *uninorth_reg, *uninorth_bus_range, *uninorth_ranges;
843 unsigned char *macio_aa, *ata_interrupts, *ata_reg;
844 struct of_device *
ic;
845 const char *n =
"pci@e2000000";
846 const char *macio =
"mac-io";
848 of_add_device(ofd, n,
"/");
849 of_add_prop_str(machine, ofd, n,
"name",
"pci");
850 of_add_prop_str(machine, ofd, n,
"device_type",
"pci");
851 of_add_prop_str(machine, ofd, n,
"compatible",
"uni-north");
853 CHECK_ALLOCATION(uninorth_reg = (
unsigned char *) malloc(2 *
sizeof(uint32_t)));
854 CHECK_ALLOCATION(uninorth_bus_range = (
unsigned char *) malloc(2 *
sizeof(uint32_t)));
855 CHECK_ALLOCATION(uninorth_ranges = (
unsigned char *) malloc(12 *
sizeof(uint32_t)));
856 CHECK_ALLOCATION(macio_aa = (
unsigned char *) malloc(5 *
sizeof(uint32_t)));
857 CHECK_ALLOCATION(ata_interrupts = (
unsigned char *) malloc(6 *
sizeof(uint32_t)));
860 of_store_32bit_in_host(uninorth_reg + 0, 0xe2000000);
861 of_store_32bit_in_host(uninorth_reg + 4, 0);
862 of_add_prop(ofd, n,
"reg", uninorth_reg, 2*
sizeof(uint32_t), 0);
864 of_store_32bit_in_host(uninorth_bus_range + 0, 0);
865 of_store_32bit_in_host(uninorth_bus_range + 4, 0);
866 of_add_prop(ofd, n,
"bus-range", uninorth_bus_range,
867 2*
sizeof(uint32_t), 0);
870 of_store_32bit_in_host(uninorth_ranges + 0, 0x02000000);
871 of_store_32bit_in_host(uninorth_ranges + 4, 0);
872 of_store_32bit_in_host(uninorth_ranges + 8, 0);
873 of_store_32bit_in_host(uninorth_ranges + 12, 0xd0000000);
874 of_store_32bit_in_host(uninorth_ranges + 16, 0);
875 of_store_32bit_in_host(uninorth_ranges + 20, 0x04000000);
877 of_store_32bit_in_host(uninorth_ranges + 24, 0x01000000);
878 of_store_32bit_in_host(uninorth_ranges + 28, 0);
879 of_store_32bit_in_host(uninorth_ranges + 32, 0);
880 of_store_32bit_in_host(uninorth_ranges + 36, 0xe2000000);
881 of_store_32bit_in_host(uninorth_ranges + 40, 0);
882 of_store_32bit_in_host(uninorth_ranges + 44, 0x01000000);
883 of_add_prop(ofd, n,
"ranges", uninorth_ranges,
884 12*
sizeof(uint32_t), 0);
886 ic = of_add_device(ofd, macio,
"/");
887 memset(macio_aa, 0, 20);
888 of_store_32bit_in_host(macio_aa + 0, 15 << 11);
889 of_store_32bit_in_host(macio_aa + 8, 0xf3000000);
890 of_add_prop(ofd, macio,
"assigned-addresses", macio_aa,
891 5*
sizeof(uint32_t), 0);
894 of_add_prop_int32(ofd,
"/chosen",
"interrupt-controller", ic->handle);
896 of_add_device(ofd,
"bandit",
"/");
897 of_add_device(ofd,
"gc",
"/bandit");
898 of_add_prop(ofd,
"/bandit/gc",
"assigned-addresses", macio_aa,
899 5*
sizeof(uint32_t), 0);
904 of_add_device(ofd,
"ata",
"/bandit/gc");
905 of_add_prop_str(machine, ofd,
"/bandit/gc/ata",
"name",
"ata");
906 of_add_prop_str(machine, ofd,
"/bandit/gc/ata",
"compatible",
908 of_store_32bit_in_host(ata_interrupts + 0, 13);
909 of_store_32bit_in_host(ata_interrupts + 4, 0);
910 of_store_32bit_in_host(ata_interrupts + 8, 0);
911 of_store_32bit_in_host(ata_interrupts + 12, 0);
912 of_store_32bit_in_host(ata_interrupts + 16, 0);
913 of_store_32bit_in_host(ata_interrupts + 20, 0);
914 of_add_prop(ofd,
"/bandit/gc/ata",
"interrupts", ata_interrupts,
915 6*
sizeof(uint32_t), 0);
916 of_store_32bit_in_host(ata_reg + 0, 0x20000);
917 of_store_32bit_in_host(ata_reg + 4, 0);
918 of_store_32bit_in_host(ata_reg + 8, 0x21000);
919 of_store_32bit_in_host(ata_reg + 12, 0x22000);
920 of_store_32bit_in_host(ata_reg + 16, 0);
921 of_store_32bit_in_host(ata_reg + 20, 0);
922 of_store_32bit_in_host(ata_reg + 24, 0);
923 of_store_32bit_in_host(ata_reg + 28, 0);
924 of_add_prop(ofd,
"/bandit/gc/ata",
"reg", ata_reg,
925 8*
sizeof(uint32_t), 0);
927 snprintf(tmpstr,
sizeof(tmpstr),
"wdc addr=0xf3020000 " 928 "irq=%s.cpu[%i].gc.lo.21 addr_mult=0x10", machine->
path,
941 uint64_t fb_addr,
int fb_xsize,
int fb_ysize)
943 unsigned char *memory_reg, *memory_av;
944 unsigned char *root_address_cells, *root_size_cells;
945 unsigned char *zs_assigned_addresses;
946 struct of_device *memory_dev, *mmu, *devstdout, *devstdin;
951 memset(ofd, 0,
sizeof(
struct of_data));
953 ofd->vfb_data = vfb_data;
958 of_add_device(ofd,
"",
"");
959 of_add_prop_str(machine, ofd,
"/",
"model",
"GXemul OpenFirmware machine");
961 CHECK_ALLOCATION(root_address_cells = (
unsigned char *) malloc(1 *
sizeof(uint32_t)));
962 of_store_32bit_in_host(root_address_cells, 0);
963 of_add_prop(ofd,
"/",
"#address-cells", root_address_cells, 1 *
sizeof(uint32_t), 0);
965 CHECK_ALLOCATION(root_size_cells = (
unsigned char *) malloc(1 *
sizeof(uint32_t)));
966 of_store_32bit_in_host(root_size_cells, 0);
967 of_add_prop(ofd,
"/",
"#size-cells", root_size_cells, 1 *
sizeof(uint32_t), 0);
969 of_add_device(ofd,
"io",
"/");
970 devstdin = of_add_device(ofd,
"stdin",
"/io");
971 devstdout = of_add_device(ofd,
"stdout",
"/io");
974 fatal(
"!\n! TODO: keyboard + framebuffer for MacPPC\n!\n");
976 of_add_prop_str(machine, ofd,
"/io/stdin",
"name",
978 of_add_prop_str(machine, ofd,
"/io",
"name",
"adb");
980 of_add_prop_str(machine, ofd,
"/io/stdout",
"device_type",
982 of_add_prop_int32(ofd,
"/io/stdout",
"width", fb_xsize);
983 of_add_prop_int32(ofd,
"/io/stdout",
"height", fb_ysize);
984 of_add_prop_int32(ofd,
"/io/stdout",
"linebytes", fb_xsize * 1);
985 of_add_prop_int32(ofd,
"/io/stdout",
"depth", 8);
986 of_add_prop_int32(ofd,
"/io/stdout",
"address", fb_addr);
989 memset(zs_assigned_addresses, 0, 12);
991 of_add_prop_str(machine, ofd,
"/io/stdin",
"name",
"ch-b");
992 of_add_prop_str(machine, ofd,
"/io/stdin",
"device_type",
994 of_add_prop_int32(ofd,
"/io/stdin",
"reg", 0xf3013000);
995 of_add_prop(ofd,
"/io/stdin",
"assigned-addresses",
996 zs_assigned_addresses, 12, 0);
998 of_add_prop_str(machine, ofd,
"/io/stdout",
"device_type",
1002 of_add_device(ofd,
"cpus",
"/");
1003 for (i=0; i<machine->
ncpus; i++) {
1005 snprintf(tmp,
sizeof(tmp),
"@%x", i);
1006 of_add_device(ofd, tmp,
"/cpus");
1007 snprintf(tmp,
sizeof(tmp),
"/cpus/@%x", i);
1008 of_add_prop_str(machine, ofd, tmp,
"device_type",
"cpu");
1009 of_add_prop_int32(ofd, tmp,
"timebase-frequency",
1011 of_add_prop_int32(ofd, tmp,
"clock-frequency",
1013 of_add_prop_int32(ofd, tmp,
"reg", i);
1016 mmu = of_add_device(ofd,
"mmu",
"/");
1019 of_add_prop(ofd,
"/mmu",
"translations", NULL, 0, 0);
1021 of_add_device(ofd,
"chosen",
"/");
1022 of_add_prop_int32(ofd,
"/chosen",
"mmu", mmu->handle);
1023 of_add_prop_int32(ofd,
"/chosen",
"stdin", devstdin->handle);
1024 of_add_prop_int32(ofd,
"/chosen",
"stdout", devstdout->handle);
1026 memory_dev = of_add_device(ofd,
"memory",
"/");
1027 CHECK_ALLOCATION(memory_reg = (
unsigned char *) malloc(2 *
sizeof(uint32_t)));
1028 CHECK_ALLOCATION(memory_av = (
unsigned char *) malloc(2 *
sizeof(uint32_t)));
1030 of_store_32bit_in_host(memory_reg + 0, 0);
1032 of_store_32bit_in_host(memory_av + 0, 10 << 20);
1034 of_add_prop(ofd,
"/memory",
"reg", memory_reg, 2 *
sizeof(uint32_t), 0);
1035 of_add_prop(ofd,
"/memory",
"available", memory_av, 2*
sizeof(uint32_t),0);
1036 of_add_prop_str(machine, ofd,
"/memory",
"name",
"memory");
1037 of_add_prop_str(machine, ofd,
"/memory",
"device_type",
"memory");
1039 of_add_prop_int32(ofd,
"/chosen",
"memory", memory_dev->handle);
1042 of_add_service(ofd,
"call-method", of__call_method_2_2, 2, 2);
1043 of_add_service(ofd,
"call-method", of__call_method_3_4, 3, 4);
1044 of_add_service(ofd,
"call-method", of__call_method_5_2, 5, 2);
1045 of_add_service(ofd,
"call-method", of__call_method_6_1, 6, 1);
1046 of_add_service(ofd,
"call-method", of__call_method_6_2, 6, 2);
1047 of_add_service(ofd,
"child", of__child, 1, 1);
1048 of_add_service(ofd,
"claim", of__claim, 3, 1);
1049 of_add_service(ofd,
"exit", of__exit, 0, 0);
1050 of_add_service(ofd,
"finddevice", of__finddevice, 1, 1);
1051 of_add_service(ofd,
"getprop", of__getprop, 4, 1);
1052 of_add_service(ofd,
"getproplen", of__getproplen, 2, 1);
1053 of_add_service(ofd,
"instance-to-package",
1054 of__instance_to_package, 1, 1);
1055 of_add_service(ofd,
"interpret", of__interpret_1, 1, 1);
1056 of_add_service(ofd,
"interpret", of__interpret_2, 1, 2);
1057 of_add_service(ofd,
"package-to-path", of__package_to_path, 3, 1);
1058 of_add_service(ofd,
"parent", of__parent, 1, 1);
1059 of_add_service(ofd,
"peer", of__peer, 1, 1);
1060 of_add_service(ofd,
"open", of__open, 1, 1);
1061 of_add_service(ofd,
"read", of__read, 3, 1);
1062 of_add_service(ofd,
"write", of__write, 3, 1);
1080 int i, nargs, nret, ofs, retval = 0;
1082 char *arg[OF_N_MAX_ARGS];
1084 struct of_service *os;
1087 if (of_data == NULL) {
1088 fatal(
"of_emul(): no of_data struct?\n");
1108 default:
fatal(
"of_emul(): unimplemented arch (TODO)\n");
1117 readstr(cpu, ptr, service,
sizeof(service));
1119 debug(
"[ of: %s(", service);
1121 for (i=0; i<nargs; i++) {
1125 if (i >= OF_N_MAX_ARGS) {
1126 fatal(
"TOO MANY ARGS!");
1133 memset(arg[i], 0, OF_ARG_MAX_LEN + 1);
1136 if (x > -256 && x < 256) {
1139 readstr(cpu, ptr, arg[i], OF_ARG_MAX_LEN);
1141 debug(
"\"%s\"", arg[i]);
1145 ofs +=
sizeof(uint32_t);
1151 os = of_data->of_services;
1152 while (os != NULL) {
1153 if (strcmp(service, os->name) == 0 &&
1154 nargs == os->n_args && nret == os->n_ret_args) {
1155 retval = os->f(cpu, arg, base, ofs);
1165 fatal(
"[ of: unimplemented service \"%s\" with %i input " 1166 "args and %i output values ]\n", service, nargs, nret);
1171 for (i=0; i<nargs; i++)
1177 cpu->
cd.
arm.
r[0] = retval;
1182 default:
fatal(
"of_emul(): TODO: unimplemented arch (Retval)\n");
void fatal(const char *fmt,...)
#define DEBUG_INDENTATION
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
int diskimage_exist(struct machine *machine, int id, int type)
struct arm_instr_call * ic
void of_emul_init_zs(struct machine *machine)
OF_SERVICE(call_method_2_2)
void f(int s, int func, int only_name)
void console_putchar(int handle, int ch)
int console_readchar(int handle)
int of_emul(struct cpu *cpu)
void * device_add(struct machine *machine, const char *name_and_params)
#define CHECK_ALLOCATION(ptr)
struct of_data * of_emul_init(struct machine *machine, struct vfb_data *vfb_data, uint64_t fb_addr, int fb_xsize, int fb_ysize)
int(* memory_rw)(struct cpu *cpu, struct memory *mem, uint64_t vaddr, unsigned char *data, size_t len, int writeflag, int cache_flags)
void cpu_register_dump(struct machine *m, struct cpu *cpu, int gprs, int coprocs)
void of_emul_init_isa(struct machine *machine)
void COMBINE() strlen(struct cpu *cpu, struct arm_instr_call *ic, int low_addr)
uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr)
void debug_indentation(int diff)
void of_emul_init_uninorth(struct machine *machine)
void of_emul_init_adb(struct machine *machine)
unsigned char rgb_palette[256 *3]