/[gxemul]/trunk/src/promemul/of.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/promemul/of.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by dpavlin, Mon Oct 8 16:20:40 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2005-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: of.c,v 1.19 2006/07/26 23:21:48 debug Exp $   *  $Id: of.c,v 1.22 2007/02/16 17:17:51 debug Exp $
29   *   *
30   *  OpenFirmware emulation.   *  OpenFirmware emulation.
31   *   *
# Line 163  OF_SERVICE(call_method_5_2) Line 163  OF_SERVICE(call_method_5_2)
163  {  {
164          if (strcmp(arg[0], "set-colors") == 0) {          if (strcmp(arg[0], "set-colors") == 0) {
165                  /*  Used by OpenBSD/macppc:  */                  /*  Used by OpenBSD/macppc:  */
166                  struct vfb_data *v = cpu->machine->of_data->vfb_data;                  struct vfb_data *v = cpu->machine->md.of_data->vfb_data;
167                  int color = OF_GET_ARG(3);                  int color = OF_GET_ARG(3);
168                  uint64_t ptr = OF_GET_ARG(4);                  uint64_t ptr = OF_GET_ARG(4);
169                  unsigned char rgb[3];                  unsigned char rgb[3];
# Line 199  OF_SERVICE(call_method_6_2) Line 199  OF_SERVICE(call_method_6_2)
199    
200  OF_SERVICE(child)  OF_SERVICE(child)
201  {  {
202          struct of_device *od = cpu->machine->of_data->of_devices;          struct of_device *od = cpu->machine->md.of_data->of_devices;
203          int handle = OF_GET_ARG(0);          int handle = OF_GET_ARG(0);
204          OF_FIND(od, od->parent == handle);          OF_FIND(od, od->parent == handle);
205          store_32bit_word(cpu, base + retofs, od == NULL? 0 : od->handle);          store_32bit_word(cpu, base + retofs, od == NULL? 0 : od->handle);
# Line 216  OF_SERVICE(exit) Line 216  OF_SERVICE(exit)
216    
217  OF_SERVICE(finddevice)  OF_SERVICE(finddevice)
218  {  {
219          int h = find_device_handle(cpu->machine->of_data, arg[0]);          int h = find_device_handle(cpu->machine->md.of_data, arg[0]);
220          store_32bit_word(cpu, base + retofs, h);          store_32bit_word(cpu, base + retofs, h);
221          return h>0? 0 : -1;          return h>0? 0 : -1;
222  }  }
# Line 224  OF_SERVICE(finddevice) Line 224  OF_SERVICE(finddevice)
224    
225  OF_SERVICE(getprop)  OF_SERVICE(getprop)
226  {  {
227          struct of_device *od = cpu->machine->of_data->of_devices;          struct of_device *od = cpu->machine->md.of_data->of_devices;
228          struct of_device_property *pr;          struct of_device_property *pr;
229          int handle = OF_GET_ARG(0), i, len_returned = 0;          int handle = OF_GET_ARG(0), i, len_returned = 0;
230          uint64_t buf = OF_GET_ARG(2);          uint64_t buf = OF_GET_ARG(2);
# Line 271  ret: Line 271  ret:
271    
272  OF_SERVICE(getproplen)  OF_SERVICE(getproplen)
273  {  {
274          struct of_device *od = cpu->machine->of_data->of_devices;          struct of_device *od = cpu->machine->md.of_data->of_devices;
275          struct of_device_property *pr;          struct of_device_property *pr;
276          int handle = OF_GET_ARG(0);          int handle = OF_GET_ARG(0);
277    
# Line 348  OF_SERVICE(package_to_path) Line 348  OF_SERVICE(package_to_path)
348    
349  OF_SERVICE(parent)  OF_SERVICE(parent)
350  {  {
351          struct of_device *od = cpu->machine->of_data->of_devices;          struct of_device *od = cpu->machine->md.of_data->of_devices;
352          int handle = OF_GET_ARG(0);          int handle = OF_GET_ARG(0);
353          OF_FIND(od, od->handle == handle);          OF_FIND(od, od->handle == handle);
354          store_32bit_word(cpu, base + retofs, od == NULL? 0 : od->parent);          store_32bit_word(cpu, base + retofs, od == NULL? 0 : od->parent);
# Line 358  OF_SERVICE(parent) Line 358  OF_SERVICE(parent)
358    
359  OF_SERVICE(peer)  OF_SERVICE(peer)
360  {  {
361          struct of_device *od = cpu->machine->of_data->of_devices;          struct of_device *od = cpu->machine->md.of_data->of_devices;
362          int handle = OF_GET_ARG(0), parent = 0, peer = 0, seen_self = 1;          int handle = OF_GET_ARG(0), parent = 0, peer = 0, seen_self = 1;
363    
364          if (handle == 0) {          if (handle == 0) {
# Line 375  OF_SERVICE(peer) Line 375  OF_SERVICE(peer)
375          parent = od->parent;          parent = od->parent;
376          seen_self = 0;          seen_self = 0;
377    
378          od = cpu->machine->of_data->of_devices;          od = cpu->machine->md.of_data->of_devices;
379    
380          while (od != NULL) {          while (od != NULL) {
381                  if (od->parent == parent) {                  if (od->parent == parent) {
# Line 689  static void of_add_prop_str(struct machi Line 689  static void of_add_prop_str(struct machi
689   */   */
690  void of_emul_init_isa(struct machine *machine)  void of_emul_init_isa(struct machine *machine)
691  {  {
692          struct of_data *ofd = machine->of_data;          struct of_data *ofd = machine->md.of_data;
693          unsigned char *isa_ranges;          unsigned char *isa_ranges;
694    
695          of_add_device(ofd, "isa", "/");          of_add_device(ofd, "isa", "/");
# Line 720  bad: Line 720  bad:
720   */   */
721  void of_emul_init_adb(struct machine *machine)  void of_emul_init_adb(struct machine *machine)
722  {  {
723          struct of_data *ofd = machine->of_data;          struct of_data *ofd = machine->md.of_data;
724          unsigned char *adb_interrupts, *adb_reg;          unsigned char *adb_interrupts, *adb_reg;
725    
726          adb_interrupts = malloc(4 * sizeof(uint32_t));          adb_interrupts = malloc(4 * sizeof(uint32_t));
# Line 760  bad: Line 760  bad:
760   */   */
761  void of_emul_init_zs(struct machine *machine)  void of_emul_init_zs(struct machine *machine)
762  {  {
763          struct of_data *ofd = machine->of_data;          struct of_data *ofd = machine->md.of_data;
764          unsigned char *zs_interrupts, *zs_reg;          unsigned char *zs_interrupts, *zs_reg;
765    
766          zs_reg = malloc(6 * sizeof(uint32_t));          zs_reg = malloc(6 * sizeof(uint32_t));
# Line 836  bad: Line 836  bad:
836   */   */
837  void of_emul_init_uninorth(struct machine *machine)  void of_emul_init_uninorth(struct machine *machine)
838  {  {
839          struct of_data *ofd = machine->of_data;          struct of_data *ofd = machine->md.of_data;
840          unsigned char *uninorth_reg, *uninorth_bus_range, *uninorth_ranges;          unsigned char *uninorth_reg, *uninorth_bus_range, *uninorth_ranges;
841          unsigned char *macio_aa, *ata_interrupts, *ata_reg;          unsigned char *macio_aa, *ata_interrupts, *ata_reg;
842          struct of_device *ic;          struct of_device *ic;
# Line 902  void of_emul_init_uninorth(struct machin Line 902  void of_emul_init_uninorth(struct machin
902    
903          if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||          if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
904              diskimage_exist(machine, 1, DISKIMAGE_IDE)) {              diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
905                    char tmpstr[400];
906                  of_add_device(ofd, "ata", "/bandit/gc");                  of_add_device(ofd, "ata", "/bandit/gc");
907                  of_add_prop_str(machine, ofd, "/bandit/gc/ata", "name", "ata");                  of_add_prop_str(machine, ofd, "/bandit/gc/ata", "name", "ata");
908                  of_add_prop_str(machine, ofd, "/bandit/gc/ata", "compatible",                  of_add_prop_str(machine, ofd, "/bandit/gc/ata", "compatible",
# Line 924  void of_emul_init_uninorth(struct machin Line 925  void of_emul_init_uninorth(struct machin
925                  of_store_32bit_in_host(ata_reg + 28, 0);                  of_store_32bit_in_host(ata_reg + 28, 0);
926                  of_add_prop(ofd, "/bandit/gc/ata", "reg", ata_reg,                  of_add_prop(ofd, "/bandit/gc/ata", "reg", ata_reg,
927                      8*sizeof(uint32_t), 0);                      8*sizeof(uint32_t), 0);
928                  device_add(machine, "wdc addr=0xf3020000 irq=21 "  
929                      "addr_mult=0x10");                  snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0xf3020000 "
930                        "irq=%s.cpu[%i].gc.lo.21 addr_mult=0x10", machine->path,
931                        machine->bootstrap_cpu);
932                    device_add(machine, tmpstr);
933          }          }
934    
935          return;          return;
# Line 1057  struct of_data *of_emul_init(struct mach Line 1061  struct of_data *of_emul_init(struct mach
1061          if (verbose >= 2)          if (verbose >= 2)
1062                  of_dump_all(ofd);                  of_dump_all(ofd);
1063    
1064          machine->of_data = ofd;          machine->md.of_data = ofd;
1065          return ofd;          return ofd;
1066    
1067  bad:  bad:
# Line 1078  int of_emul(struct cpu *cpu) Line 1082  int of_emul(struct cpu *cpu)
1082          char *arg[OF_N_MAX_ARGS];          char *arg[OF_N_MAX_ARGS];
1083          uint64_t base, ptr;          uint64_t base, ptr;
1084          struct of_service *os;          struct of_service *os;
1085          struct of_data *of_data = cpu->machine->of_data;          struct of_data *of_data = cpu->machine->md.of_data;
1086    
1087          if (of_data == NULL) {          if (of_data == NULL) {
1088                  fatal("of_emul(): no of_data struct?\n");                  fatal("of_emul(): no of_data struct?\n");

Legend:
Removed from v.30  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26