/[pearpc]/src/io/prom/promdt.cc
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /src/io/prom/promdt.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Wed Sep 5 17:11:21 2007 UTC (16 years, 6 months ago) by dpavlin
File size: 51121 byte(s)
import upstream CVS
1 /*
2 * PearPC
3 * promdt.cc
4 *
5 * Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include <cstring>
22 #include <cstdlib>
23 #include "debug/tracers.h"
24 #include "tools/debug.h"
25 #include "cpu/cpu.h"
26 #include "cpu/mem.h"
27 #include "io/graphic/gcard.h"
28 #include "io/cuda/cuda.h"
29 #include "io/pic/pic.h"
30 #include "io/ide/ide.h"
31 #include "io/3c90x/3c90x.h"
32 #include "io/rtl8139/rtl8139.h"
33 #include "system/arch/sysendian.h"
34 #include "system/keyboard.h"
35 #include "system/display.h"
36 #include "prommem.h"
37 #include "promdt.h"
38 #include "tools/except.h"
39
40 #include "info.h"
41
42 PromNode *gPromRoot;
43 AVLTree *gPromPackages;
44 AVLTree *gPromInstances;
45 int gBootPartNum = -1;
46 int gBootNodeID = -1;
47
48 int PromNode::promNodeHandles = 1;
49
50 class PromKV: public Object {
51 public:
52 Object *mKey, *mValue;
53 PromKV(Object *aKey, Object *aValue)
54 {
55 mKey = aKey;
56 mValue = aValue;
57 }
58
59 ~PromKV()
60 {
61 delete mKey;
62 }
63
64 virtual int compareTo(const Object *obj) const
65 {
66 return mKey->compareTo(((PromKV*)obj)->mKey);
67 }
68
69 };
70
71 void registerPackage(PromPackageHandle ph, PromNode *pn)
72 {
73 gPromPackages->insert(new PromKV(new UInt(ph), pn));
74 }
75
76 void registerInstance(PromInstanceHandle ih, PromInstance *pi)
77 {
78 gPromInstances->insert(new PromKV(new UInt(ih), pi));
79 }
80
81 void unregisterInstance(PromInstanceHandle ih)
82 {
83 PromKV pio(new UInt(ih), NULL);
84 gPromInstances->del(gPromInstances->find(&pio));
85 }
86
87 PromNode *handleToPackage(PromPackageHandle ph)
88 {
89 PromKV pho(new UInt(ph), NULL);
90 PromKV *kv = (PromKV *)gPromPackages->get(gPromPackages->find(&pho));
91 return kv ? (PromNode *)kv->mValue : 0;
92 }
93
94 PromInstance *handleToInstance(PromInstanceHandle ih)
95 {
96 PromKV pio(new UInt(ih), NULL);
97 PromKV *kv = (PromKV *)gPromInstances->get(gPromInstances->find(&pio));
98 return kv ? (PromInstance *)kv->mValue : 0;
99 }
100
101 /*
102 *
103 */
104 PromObject::PromObject(const char *aName)
105 :Object()
106 {
107 name = strdup(aName);
108 owner = NULL;
109 }
110
111 PromObject::~PromObject()
112 {
113
114 free(name);
115 }
116
117 int PromObject::compareTo(const Object *obj) const
118 {
119 return strcmp(name, ((PromNode*)obj)->name);
120 }
121
122 ObjectID PromObject::getObjectID() const
123 {
124 return ATOM_PROM_OBJECT;
125 }
126
127 void PromObject::setOwner(PromNode *aOwner)
128 {
129 owner = aOwner;
130 }
131
132 uint32 PromObject::toPath(char *buf, uint32 buflen)
133 {
134 if (owner) {
135 uint32 s = owner->toPath(buf, buflen);
136 // XXX
137 if (owner != gPromRoot) strcat(buf, "/");
138 strcat(buf, name);
139 return s+1+strlen(name);
140 } else {
141 if (buflen > 1) {
142 strcpy(buf, "/");
143 }
144 return 1;
145 }
146 }
147
148 /*
149 *
150 */
151 PromNode::PromNode(const char *aName)
152 :PromObject(aName)
153 {
154 childs = new AVLTree(true);
155 props = new AVLTree(true);
156 shortcuts = new AVLTree(true);
157
158 String nodeaddr(aName), nodename, unitaddr;
159 nodeaddr.leftSplit('@', nodename, unitaddr);
160 PromPropString *pn = new PromPropString("name", nodename.contentChar());
161 addProp(pn);
162 mPromNodeHandle = promNodeHandles++;
163 mPromNodeInstancesHandles = 0;
164 registerPackage(mPromNodeHandle, this);
165 }
166
167 PromNode::~PromNode()
168 {
169 delete childs;
170 delete props;
171 delete shortcuts;
172 }
173
174 ObjectID PromNode::getObjectID() const
175 {
176 return ATOM_PROM_NODE;
177 }
178
179 bool PromNode::addNode(PromNode *node)
180 {
181 if (childs->insert(node)) {
182 node->setOwner(this);
183 return true;
184 } else {
185 return false;
186 }
187 }
188
189 bool PromNode::addProp(PromProp *node)
190 {
191 if (props->insert(node)) {
192 node->setOwner(this);
193 return true;
194 } else {
195 return false;
196 }
197 }
198
199 bool PromNode::addNodeShort(const char *name, const char *node)
200 {
201 KeyValue *kv = new KeyValue(new String(name), new String(node));
202 if (shortcuts->insert(kv)) {
203 return true;
204 } else {
205 delete kv;
206 return false;
207 }
208 }
209
210 PromNode *PromNode::findNode(const char *name)
211 {
212 PromNode empty(name);
213 ObjHandle oh = childs->find(&empty);
214 if (oh == InvObjHandle) {
215 KeyValue empty2(new String(name), NULL);
216 oh = shortcuts->find(&empty2);
217 if (oh != InvObjHandle) {
218 PromNode empty3(((String *)((KeyValue *)shortcuts->get(oh))->mValue)->contentChar());
219 oh = childs->find(&empty3);
220 return (PromNode*)childs->get(oh);
221 }
222 } else {
223 return (PromNode*)childs->get(oh);
224 }
225 return NULL;
226 }
227
228 PromProp *PromNode::findProp(const char *name)
229 {
230 PromProp empty(name);
231 ObjHandle oh = props->find(&empty);
232 return (oh == InvObjHandle) ? NULL : (PromProp*)props->get(oh);
233 }
234
235 PromNode *PromNode::firstChild()
236 {
237 return (PromNode*)childs->get(childs->findFirst());
238 }
239
240 PromNode *PromNode::nextChild(PromNode *p)
241 {
242 ObjHandle oh = childs->find(p);
243 return (oh == InvObjHandle) ? NULL : (PromNode*)childs->get(childs->findNext(childs->find(p)));
244 }
245
246 PromProp *PromNode::firstProp()
247 {
248 return (PromProp*)props->get(props->findFirst());
249
250 }
251
252 PromProp *PromNode::nextProp(PromProp *p)
253 {
254 ObjHandle oh = props->find(p);
255 return (oh == InvObjHandle) ? NULL : (PromProp*)props->get(props->findNext(props->find(p)));
256 }
257
258 PromInstanceHandle PromNode::open(const String &param)
259 {
260 PromInstance *pi = createInstance(param);
261 if (pi) {
262 PromInstanceHandle pih = (mPromNodeHandle<<16) | (mPromNodeInstancesHandles++);
263 pi->setIHandle(pih);
264 registerInstance(pih, pi);
265 return pih;
266 } else {
267 IO_PROM_WARN("%s: can't create instance\n", name);
268 return 0;
269 }
270 }
271
272 void PromNode::close(PromInstanceHandle pih)
273 {
274 PromInstance *pi = handleToInstance(pih);
275 if (pi) {
276 unregisterInstance(pih);
277 delete pi;
278 }
279 }
280
281 PromPackageHandle PromNode::getPHandle()
282 {
283 return mPromNodeHandle;
284 }
285
286 PromInstance *PromNode::createInstance(const String &param)
287 {
288 return NULL;
289 }
290
291 /*
292 *
293 */
294 PromProp::PromProp(const char *aName)
295 :PromObject(aName)
296 {
297 }
298
299 ObjectID PromProp::getObjectID() const
300 {
301 return ATOM_PROM_PROP;
302 }
303
304 uint32 PromProp::getValueLen()
305 {
306 return 0;
307 }
308
309 uint32 PromProp::getValue(uint32 buf, uint32 buflen)
310 {
311 return (uint32)-1;
312 }
313
314 uint32 PromProp::setValue(uint32 buf, uint32 buflen)
315 {
316 return (uint32)-1;
317 }
318
319 /*
320 *
321 */
322 PromInstance::PromInstance(PromNode *type, const String &param)
323 {
324 mType = type;
325 }
326
327 PromInstance::~PromInstance()
328 {
329 }
330
331 void PromInstance::setIHandle(PromInstanceHandle handle)
332 {
333 mHandle = handle;
334 }
335
336 PromNode *PromInstance::getType()
337 {
338 return mType;
339 }
340
341 void PromInstance::callMethod(const char *method, prom_args *pa)
342 {
343 IO_PROM_ERR("%s: no method '%s'\n", mType->name, method);
344 }
345
346 uint32 PromInstance::write(uint32 buf, int length)
347 {
348 IO_PROM_ERR("%s: write not implemented\n", mType->name);
349 return 0;
350 }
351
352 uint32 PromInstance::read(uint32 buf, int length)
353 {
354 IO_PROM_ERR("%s: read not implemented\n", mType->name);
355 return 0;
356 }
357
358 uint32 PromInstance::seek(uint64 pos)
359 {
360 IO_PROM_ERR("%s: seek not implemented\n", mType->name);
361 return (uint32)-1;
362 }
363
364 /*
365 *
366 */
367 PromNodeATY::PromNodeATY(const char *name)
368 :PromNode(name)
369 {
370 }
371
372 PromInstance *PromNodeATY::createInstance(const String &param)
373 {
374 return new PromInstanceATY(this, param);
375 }
376 /*
377 *
378 */
379 PromInstanceATY::PromInstanceATY(PromNode *type, const String &param)
380 :PromInstance(type, param)
381 {
382 }
383
384 void PromInstanceATY::callMethod(const char *method, prom_args *pa)
385 {
386 // va->args[] = ;
387 if (strcmp(method, "color!") == 0) {
388 pa->args[6] = 0;
389 } else if (strcmp(method, "draw-rectangle") == 0) {
390 uint32 data = pa->args[6];
391 uint32 x = pa->args[5];
392 uint32 y = pa->args[4];
393 uint32 width = pa->args[3];
394 uint32 height = pa->args[2];
395 uint32 bpp = gDisplay->mClientChar.bytesPerPixel;
396 byte *f = gFrameBuffer + (y*gDisplay->mClientChar.width + x)*bpp;
397 for (uint iy = 0; iy < height; iy++) {
398 for (uint ix = 0; ix < width; ix++) {
399 uint32 phys;
400 ppc_prom_effective_to_physical(phys, data);
401 byte v[4];
402 ppc_dma_read(v, phys, bpp);
403 for (uint i=0; i<bpp; i++) *(f++) = v[i];
404 /* switch (bpp) {
405 case 1: {
406 uint8 v;
407 ppc_read_effective_byte(data, v);
408 *(f++) = v;
409 break;
410 }
411 case 2: {
412 uint16 v;
413 ppc_read_effective_half(data, v);
414 *(f++) = v>>8;
415 *(f++) = v;
416 break;
417 }
418 case 4: {
419 uint32 v;
420 ppc_read_effective_word(data, v);
421 *(f++) = v>>24;
422 *(f++) = v>>16;
423 *(f++) = v>>8;
424 *(f++) = v;
425 break;
426 }
427 }*/
428 data += bpp;
429 }
430 f += gDisplay->mClientChar.scanLineLength - width*bpp;
431 }
432 damageFrameBufferAll();
433 pa->args[7] = 0;
434 } else if (strcmp(method, "fill-rectangle") == 0) {
435 uint32 color = pa->args[6];
436 uint32 x = pa->args[5];
437 uint32 y = pa->args[4];
438 uint32 width = pa->args[3];
439 uint32 height = pa->args[2];
440 uint32 bpp = gDisplay->mClientChar.bytesPerPixel;
441 uint32 f = y*(gDisplay->mClientChar.width + x)*bpp;
442 for (uint iy=0; iy < height; iy++) {
443 for (uint ix=0; ix < width; ix++) {
444 if (bpp > 2) {
445 gFrameBuffer[f++] = color >> 24;
446 gFrameBuffer[f++] = color >> 16;
447 }
448 if (bpp > 1) gFrameBuffer[f++] = color >> 8;
449 gFrameBuffer[f++] = color;
450 }
451 f += gDisplay->mClientChar.scanLineLength - width*bpp;
452 }
453 damageFrameBufferAll();
454 pa->args[7] = 0;
455 } else {
456 IO_PROM_ERR("%s: %s not implemented\n", mType->name, method);
457 }
458 }
459
460 uint32 PromInstanceATY::write(uint32 buf, int length)
461 {
462 uint32 phys;
463 ppc_prom_effective_to_physical(phys, buf);
464 byte *mbuf = (byte *)malloc(length);
465 ppc_dma_read(mbuf, phys, length);
466 String s(mbuf, length);
467 free(mbuf);
468 gDisplay->printf("%y", &s);
469 return length;
470 }
471
472 /*
473 *
474 */
475 PromNodeKBD::PromNodeKBD(const char *name)
476 :PromNode(name)
477 {
478 }
479
480 PromInstance *PromNodeKBD::createInstance(const String &param)
481 {
482 return new PromInstanceKBD(this, param);
483 }
484 /*
485 *
486 */
487 PromInstanceKBD::PromInstanceKBD(PromNode *type, const String &param)
488 :PromInstance(type, param)
489 {
490 }
491
492 uint32 PromInstanceKBD::read(uint32 buf, int length)
493 {
494 uint32 phys;
495
496 if (ppc_prom_effective_to_physical(phys, buf)) {
497 uint32 key;
498 char chr;
499 if (cuda_prom_get_key(key)
500 && !(key & 0x80) // ignore KeyUp events
501 && gKeyboard->adbKeyToAscii(chr, key))
502 {
503 ppc_dma_write(phys, &chr, 1);
504 return 1;
505 }
506 }
507 return 0;
508 }
509
510 /*
511 *
512 */
513 PromNodeRTAS::PromNodeRTAS(const char *name)
514 :PromNode(name)
515 {
516 }
517
518 PromInstance *PromNodeRTAS::createInstance(const String &param)
519 {
520 return new PromInstanceRTAS(this, param);
521 }
522
523 /*
524 *
525 */
526 PromInstanceRTAS::PromInstanceRTAS(PromNode *type, const String &param)
527 :PromInstance(type, param)
528 {
529 }
530
531 uint32 PromInstanceRTAS::write(uint32 buf, int length)
532 {
533 // String s((byte*)prom_ea_string(buf), length);
534 // IO_PROM_TRACE("RTAS: '%y'\n", &s);
535 return length;
536 }
537
538 void PromInstanceRTAS::callMethod(const char *method, prom_args *pa)
539 {
540 // va->args[] = ;
541 if (strcmp(method, "instantiate-rtas") == 0) {
542 // instantiate-rtas(void *rtas_data, int ret1, int rtas_entry)
543 pa->args[3] = 0;
544 pa->args[4] = 0;
545 } else {
546 }
547 }
548
549 /*
550 *
551 */
552 PromNodeMMU::PromNodeMMU(const char *name)
553 :PromNode(name)
554 {
555 }
556
557 PromInstance *PromNodeMMU::createInstance(const String &param)
558 {
559 return new PromInstanceMMU(this, param);
560 }
561
562 /*
563 *
564 */
565 PromInstanceMMU::PromInstanceMMU(PromNode *type, const String &param)
566 :PromInstance(type, param)
567 {
568 }
569
570 void PromInstanceMMU::callMethod(const char *method, prom_args *pa)
571 {
572 if (strcmp(method, "translate") == 0) {
573 uint32 virt = pa->args[2];
574 IO_PROM_TRACE("mmu->translate(%08x)\n", virt);
575 uint32 phys;
576 if (!ppc_prom_effective_to_physical(phys, virt)) {
577 IO_PROM_ERR("translate failed\n");
578 } else {
579 pa->args[4] = 0;
580 pa->args[5] = 0;
581 pa->args[6] = 0;
582 pa->args[7] = phys;
583 }
584 IO_PROM_TRACE("=%08x\n", phys);
585 // gSinglestep = true;
586 return;
587 } else if (strcmp(method, "claim") == 0) {
588 // claim virtual memory
589 // mmu->claim(ihandle, "claim", virt, size, align, *addr);
590 uint32 virt = pa->args[4];
591 uint32 size UNUSED = pa->args[3];
592 uint32 align UNUSED = pa->args[2];
593 IO_PROM_TRACE("mmu->claim(%08x, %08x, %08x)\n", virt, size, align);
594 pa->args[5] = 0;
595 pa->args[6] = virt;
596 return;
597 } else if (strcmp(method, "map") == 0) {
598 //
599 uint32 phys = pa->args[5];
600 uint32 virt = pa->args[4];
601 uint32 size = pa->args[3];
602 uint32 mode UNUSED = pa->args[2];
603 IO_PROM_TRACE("mmu->map(%08x, %08x, %08x, %08x)\n", phys, virt, size, mode);
604 for (uint32 p=phys; p<(phys+size); p+=4096) {
605 ppc_prom_page_create(virt, p);
606 virt += 4096;
607 }
608 pa->args[6] = 0;
609 return;
610 } else if (strcmp(method, "unmap") == 0) {
611 uint32 virt UNUSED = pa->args[3];
612 uint32 size UNUSED = pa->args[2];
613 IO_PROM_TRACE("mmu->unmap(%08x, %08x)\n", virt, size);
614 pa->args[4] = 0;
615 return;
616 }
617 IO_PROM_ERR("mmu: %s not impl\n", method);
618 }
619
620 uint32 PromInstanceMMU::write(uint32 buf, int length)
621 {
622 return 0;
623 }
624
625 /*
626 *
627 */
628 PromNodeMemory::PromNodeMemory(const char *name)
629 :PromNode(name)
630 {
631 }
632
633 PromInstance *PromNodeMemory::createInstance(const String &param)
634 {
635 return new PromInstanceMemory(this, param);
636 }
637
638 /*
639 *
640 */
641 PromInstanceMemory::PromInstanceMemory(PromNode *type, const String &param)
642 :PromInstance(type, param)
643 {
644 }
645
646 void PromInstanceMemory::callMethod(const char *method, prom_args *pa)
647 {
648 if (strcmp(method, "claim") == 0) {
649 // claim physical memory
650 // memory->claim(ihandle, "claim", virt, size, align, *addr);
651 uint32 virt = pa->args[4];
652 uint32 size = pa->args[3];
653 uint32 align UNUSED = pa->args[2];
654 IO_PROM_TRACE("memory->claim(%08x, %08x, %08x)\n", virt, size, align);
655 if (!prom_claim_pages(virt, size)) {
656 IO_PROM_ERR("memory->claim failed!\n");
657 }
658 pa->args[5] = 0;
659 pa->args[6] = virt;
660 return;
661 }
662 IO_PROM_ERR("memory: %s not impl\n", method);
663 }
664
665 /*
666 *
667 */
668 PromNodeDisk::PromNodeDisk(const char *name, int aNumber)
669 :PromNode(name)
670 {
671 mNumber = aNumber;
672
673 IDEConfig *ic = ide_get_config(mNumber);
674 File *rawFile = ic->device->promGetRawFile();
675 pm = partitions_get_map(rawFile, ic->device->getBlockSize());
676 delete rawFile;
677
678 mDevice = NULL;
679 mFS = NULL;
680
681 String type;
682 pm->getType(type);
683 }
684
685 PromNodeDisk::~PromNodeDisk()
686 {
687 delete pm;
688 delete mFS;
689 delete mDevice;
690 }
691
692 PromInstance *PromNodeDisk::createInstance(const String &param)
693 {
694 IO_PROM_TRACE("PromNodeDisk::createInstance, param='%s'\n", param.contentChar());
695 String part, file;
696 if (param.findFirstChar(',') != -1) {
697 param.leftSplit(',', part, file);
698 } else if (param.length()) {
699 if ((param.firstChar() >= '0') && (param.firstChar() <= '9')) {
700 part.assign(param);
701 } else {
702 file.assign(param);
703 }
704 }
705 IO_PROM_TRACE("part = '%y', file = '%y'\n", &part, &file);
706 uint32 partNumber;
707 if (!part.toInt32(partNumber)) partNumber = 0;
708 if (file.length() == 0) {
709 return new PromInstanceDiskPart(this, partNumber);
710 } else {
711 if (partNumber == 0) {
712 if (getPHandle() == gBootNodeID) {
713 partNumber = gBootPartNum; // FIXME: HACK. we don't know how to do this correctly...
714 } else {
715 IO_PROM_WARN("can't determine boot partition number\n");
716 return NULL;
717 }
718 }
719 PartitionEntry *pe = (PartitionEntry*)((*pm->getPartitions())[partNumber]);
720 char *f = file.contentChar();
721 file.translate("\\", "/");
722 int flen = file.length();
723 if (!pe || !pe->mInstantiateFileSystem) {
724 IO_PROM_WARN("can't instantiate file system\n");
725 return NULL;
726 }
727 // FIXME: HACK
728 IDEConfig *ic = ide_get_config(mNumber);
729 if (!mDevice) mDevice = ic->device->promGetRawFile();
730 if (!mFS) mFS = pe->mInstantiateFileSystem(mDevice, partNumber);
731 String filename;
732 File *file = NULL;
733 if ((flen >= 2) && ((f[0] == '/') && (f[1] == '/'))) {
734 IO_PROM_TRACE("FS: in boot path\n");
735 if (mFS->getBlessedPath(filename)) {
736 filename.append(f+2);
737 }
738 } else {
739 // FIXME: won't work
740 filename.assign(f);
741 }
742 IO_PROM_TRACE("FS: opening '%y'\n", &filename);
743 file = mFS->open(filename);
744 if (file) {
745 IO_PROM_TRACE("FS: file found!\n");
746 return new PromInstanceDiskFile(this, file);
747 } else {
748 IO_PROM_TRACE("FS: file NOT found!\n");
749 }
750 }
751 return NULL;
752 }
753
754 /*
755 *
756 */
757 PromInstanceDiskFile::PromInstanceDiskFile(PromNode *type, File *file)
758 :PromInstance(type, "")
759 {
760 mFile = file;
761 }
762
763 void PromInstanceDiskFile::callMethod(const char *method, prom_args *pa)
764 {
765 /* if (strcmp(method, "block-size") == 0) {
766 IO_PROM_TRACE("disk->block-size()\n");
767 pa->args[2] = 0;
768 IDEConfig *ic = ide_get_config(mNumber);
769 pa->args[3] = ic->bps;
770 } else if (strcmp(method, "dma-alloc") == 0) {
771 uint32 size UNUSED = pa->args[4];
772 uint32 a2 UNUSED = pa->args[3];
773 uint32 a1 UNUSED = pa->args[2];
774 IO_PROM_TRACE("disk->dma-alloc(%x, %x, %x)\n", a1, a2, size);
775 pa->args[5] = 0;
776 pa->args[6] = 1;
777 } else if (strcmp(method, "dma-free") == 0) {
778 uint32 size UNUSED = pa->args[5];
779 uint32 addr UNUSED = pa->args[4];
780 uint32 a2 UNUSED = pa->args[3];
781 uint32 a1 UNUSED = pa->args[2];
782 IO_PROM_TRACE("disk->dma-free(%x, %x, %x, %x)\n", a1, a2, addr, size);
783 pa->args[6] = 0;
784 } else {*/
785 IO_PROM_ERR("diskFile:%s not impl.\n", method);
786 // }
787 }
788
789 uint32 PromInstanceDiskFile::read(uint32 buf, int length)
790 {
791 byte *buffer = (byte *)malloc(length);
792 uint32 result = mFile->read(buffer, length);
793 uint32 phys;
794 ppc_prom_effective_to_physical(phys, buf);
795 ppc_dma_write(phys, buffer, result);
796 free(buffer);
797 return result;
798 }
799
800 uint32 PromInstanceDiskFile::write(uint32 buf, int length)
801 {
802 IO_PROM_WARN("will not write to disk file..\n");
803 return 0;
804 }
805
806 uint32 PromInstanceDiskFile::seek(uint64 pos)
807 {
808 try {
809 mFile->seek(pos);
810 } catch (const IOException &x) {
811 }
812 return 0;
813 }
814
815 /*
816 *
817 */
818 PromInstanceDiskPart::PromInstanceDiskPart(PromNode *type, uint partnum)
819 :PromInstance(type, "")
820 {
821 mNumber = ((PromNodeDisk *)type)->mNumber;
822
823 PartitionEntry *pe = (PartitionEntry*)((*((PromNodeDisk *)type)->pm->getPartitions())[partnum]);
824 mOffset = pe ? pe->mOffset : 0;
825 }
826
827 void PromInstanceDiskPart::callMethod(const char *method, prom_args *pa)
828 {
829 if (strcmp(method, "block-size") == 0) {
830 IO_PROM_TRACE("disk->block-size()\n");
831 pa->args[2] = 0;
832 IDEConfig *ic = ide_get_config(mNumber);
833 pa->args[3] = ic->bps;
834 } else if (strcmp(method, "dma-alloc") == 0) {
835 uint32 size UNUSED = pa->args[4];
836 uint32 a2 UNUSED = pa->args[3];
837 uint32 a1 UNUSED = pa->args[2];
838 IO_PROM_TRACE("disk->dma-alloc(%x, %x, %x)\n", a1, a2, size);
839 pa->args[5] = 0;
840 pa->args[6] = 1;
841 } else if (strcmp(method, "dma-free") == 0) {
842 uint32 size UNUSED = pa->args[5];
843 uint32 addr UNUSED = pa->args[4];
844 uint32 a2 UNUSED = pa->args[3];
845 uint32 a1 UNUSED = pa->args[2];
846 IO_PROM_TRACE("disk->dma-free(%x, %x, %x, %x)\n", a1, a2, addr, size);
847 pa->args[6] = 0;
848 } else {
849 IO_PROM_ERR("partDisk:%s not impl.\n", method);
850 }
851 }
852
853 uint32 PromInstanceDiskPart::read(uint32 buf, int length)
854 {
855 IDEConfig *ic = ide_get_config(mNumber);
856 byte *buffer = (byte *)malloc(length);
857 uint32 result = ic->device->promRead(buffer, length);
858 uint32 phys;
859 ppc_prom_effective_to_physical(phys, buf);
860 ppc_dma_write(phys, buffer, result);
861 free(buffer);
862 return result;
863 }
864
865 uint32 PromInstanceDiskPart::write(uint32 buf, int length)
866 {
867 IO_PROM_WARN("will not write to part disk..\n");
868 return 0;
869 }
870
871 uint32 PromInstanceDiskPart::seek(uint64 pos)
872 {
873 IDEConfig *ic = ide_get_config(mNumber);
874 ic->device->promSeek(pos + mOffset);
875 return 0;
876 }
877
878 /*
879 *
880 */
881 PromPropLink::PromPropLink(const char *aName, PromInstanceHandle aValue)
882 :PromProp(aName)
883 {
884 value = aValue;
885 }
886
887 PromPropLink::~PromPropLink()
888 {
889 }
890
891 uint32 PromPropLink::getValueLen()
892 {
893 return 4;
894 }
895
896 uint32 PromPropLink::getValue(uint32 buf, uint32 buflen)
897 {
898 uint32 phys;
899 ppc_prom_effective_to_physical(phys, buf);
900 uint32 v = ppc_word_to_BE(value);
901 ppc_dma_write(phys, &v, 4);
902 return 4;
903 }
904
905 /*
906 *
907 */
908 PromPropInt::PromPropInt(const char *aName, uint32 aValue)
909 :PromProp(aName)
910 {
911 value = aValue;
912 }
913
914 PromPropInt::~PromPropInt()
915 {
916 }
917
918 uint32 PromPropInt::getValueLen()
919 {
920 return 4;
921 }
922
923 uint32 PromPropInt::getValue(uint32 buf, uint32 buflen)
924 {
925 uint32 phys;
926 ppc_prom_effective_to_physical(phys, buf);
927 uint32 v = ppc_word_to_BE(value);
928 ppc_dma_write(phys, &v, 4);
929 return 4;
930 }
931
932 /*
933 *
934 */
935
936 PromPropMemory::PromPropMemory(const char *name, const void *aBuf, int aSize)
937 :PromProp(name)
938 {
939 size = aSize;
940 buf = malloc(size);
941 memcpy(buf, aBuf, size);
942 }
943
944 PromPropMemory::~PromPropMemory()
945 {
946 if (buf) free(buf);
947 }
948
949 uint32 PromPropMemory::getValueLen()
950 {
951 return buf ? size : 0;
952 }
953
954 uint32 PromPropMemory::getValue(uint32 aBuf, uint32 buflen)
955 {
956 if (buf && buflen && aBuf) {
957 uint32 s = MIN(buflen, (uint32)size);
958 uint32 phys;
959 ppc_prom_effective_to_physical(phys, aBuf);
960 ppc_dma_write(phys, buf, s);
961 return s;
962 } else {
963 return 0;
964 }
965 }
966
967 uint32 PromPropMemory::setValue(uint32 aBuf, uint32 buflen)
968 {
969 if (buf) free(buf);
970 if (aBuf && buflen) {
971 uint32 phys;
972 ppc_prom_effective_to_physical(phys, aBuf);
973 size = buflen;
974 buf = malloc(size);
975 ppc_dma_read(buf, phys, size);
976 return size;
977 } else {
978 buf = NULL;
979 return 0;
980 }
981 }
982
983 /*
984 *
985 */
986 PromPropString::PromPropString(const char *aName, const char *aValue)
987 :PromProp(aName)
988 {
989 value = strdup(aValue);
990 }
991
992 PromPropString::~PromPropString()
993 {
994 if (value) free(value);
995 }
996
997 uint32 PromPropString::getValueLen()
998 {
999 return value ? (strlen(value)+1) : 0;
1000 }
1001
1002 uint32 PromPropString::getValue(uint32 buf, uint32 buflen)
1003 {
1004 if (value && buflen && buf) {
1005 buflen--;
1006 uint slen = strlen(value);
1007 uint s = MIN(buflen, slen);
1008 uint32 phys;
1009 ppc_prom_effective_to_physical(phys, buf);
1010 ppc_dma_write(phys, value, s);
1011 byte null=0;
1012 ppc_dma_write(phys+s, &null, 1);
1013 return s+1;
1014 } else {
1015 return 0;
1016 }
1017 }
1018
1019 uint32 PromPropString::setValue(uint32 buf, uint32 buflen)
1020 {
1021 if (value) free(value);
1022 if (buf && buflen) {
1023 String bufchar;
1024 prom_get_string(bufchar, buf);
1025 value = (char*)malloc(buflen+1);
1026 memcpy(value, bufchar.contentChar(), buflen);
1027 value[buflen] = 0;
1028 return buflen;
1029 } else {
1030 value = NULL;
1031 return 0;
1032 }
1033 }
1034
1035 /*******************************************************************************
1036 *
1037 */
1038
1039 PromNode *findDevice(const char *aPathName, int type, PromInstanceHandle *ret)
1040 {
1041 // .39
1042 String pathname(aPathName);
1043 if (!pathname.length()) return NULL;
1044 String component, tmp, nodeaddr, arguments, nodename, unitaddr;
1045 if (!(pathname[0] == '/')) {
1046 PromNode *aliases = gPromRoot->findNode("aliases");
1047 if (aliases) {
1048 pathname.leftSplit('/', component, tmp);
1049 component.leftSplit(':', nodeaddr, arguments);
1050 nodeaddr.leftSplit('@', nodename, unitaddr);
1051 PromPropString *a = (PromPropString *)aliases->findProp(nodename.contentChar());
1052 if (a) {
1053 pathname.assign(a->value);
1054 pathname += ((unitaddr!=(String)"")?("@"+unitaddr):(String)"")+":"+arguments;
1055 } else return NULL;
1056 } else return NULL;
1057 }
1058 PromNode *pn = gPromRoot;
1059 pathname.del(0, 1);
1060 while (pathname.length()) {
1061 pathname.leftSplit('/', component, tmp);
1062 pathname = tmp;
1063 component.leftSplit(':', nodeaddr, arguments);
1064 nodeaddr.leftSplit('@', nodename, unitaddr);
1065 pn = pn->findNode(nodename.contentChar());
1066 if (!pn) return NULL;
1067 }
1068 if (type == FIND_DEVICE_OPEN) {
1069 *ret = pn->open(arguments);
1070 }
1071 return pn;
1072 }
1073
1074 #define UINT32(v) ((uint32)(v)>>24),((uint32)(v)>>16),((uint32)(v)>>8),((uint8)(uint32)(v))
1075 #define PHANDLE(v) UINT32((v)->getPHandle())
1076
1077 void prom_init_device_tree()
1078 {
1079 gPromPackages = new AVLTree(true);
1080 gPromInstances = new AVLTree(true);
1081
1082 // root
1083 gPromRoot = new PromNode("device-tree");
1084
1085 // must have
1086 PromNode *aliases = new PromNode("aliases");
1087 PromNode *chosen = new PromNode("chosen");
1088 PromNode *cpus = new PromNode("cpus");
1089 PromNode *memory = new PromNodeMemory("memory");
1090 PromNode *openprom = new PromNode("openprom");
1091 PromNode *options = new PromNode("options");
1092 PromNode *packages = new PromNode("packages");
1093 PromNode *rtas = new PromNodeRTAS("rtas");
1094 PromNode *mmu = new PromNodeMMU("mmu");
1095 PromNode *kbd = new PromNodeKBD("keyboard");
1096
1097 PromNode *rom = new PromNode("rom@ff800000");
1098 PromNode *pci = new PromNode("pci@80000000");
1099
1100 gPromRoot->addProp(new PromPropString("model", EMULATOR_MODEL));
1101 gPromRoot->addProp(new PromPropString("compatible", "PowerMac1,2\0PowerMac1,1\0MacRISC\0Power Macintosh"));
1102 gPromRoot->addProp(new PromPropString("copyright", COPYRIGHT));
1103 gPromRoot->addProp(new PromPropString("device_type", "bootrom"));
1104 gPromRoot->addProp(new PromPropString("system-id", "42"));
1105 gPromRoot->addProp(new PromPropInt("#address-cells", 1));
1106 gPromRoot->addProp(new PromPropInt("#size-cells", 1));
1107 gPromRoot->addProp(new PromPropInt("clock-frequency", 1));
1108
1109 gPromRoot->addNode(aliases);
1110 gPromRoot->addNode(chosen);
1111 gPromRoot->addNode(cpus);
1112 gPromRoot->addNode(kbd);
1113
1114 PromNode *cpu = new PromNode("PowerPC,G4");
1115 cpus->addNode(cpu);
1116 cpus->addProp(new PromPropInt("#size-cells", 0));
1117 cpu->addProp(new PromPropString("device_type", "cpu"));
1118 cpu->addProp(new PromPropInt("reg", 0));
1119 cpu->addProp(new PromPropInt("cpu-version", ppc_cpu_get_pvr(0)));
1120 cpu->addProp(new PromPropString("state", "running"));
1121 cpu->addProp(new PromPropInt("clock-frequency", ppc_get_clock_frequency(0)));
1122 cpu->addProp(new PromPropInt("timebase-frequency", ppc_get_timebase_frequency(0)));
1123 cpu->addProp(new PromPropInt("bus-frequency", ppc_get_bus_frequency(0)));
1124 cpu->addProp(new PromPropInt("reservation-granule-size", 0x20));
1125 cpu->addProp(new PromPropInt("tlb-sets", 0x40));
1126 cpu->addProp(new PromPropInt("tlb-size", 0x80));
1127 cpu->addProp(new PromPropInt("d-cache-size", 0x8000));
1128 cpu->addProp(new PromPropInt("i-cache-size", 0x8000));
1129 cpu->addProp(new PromPropInt("d-cache-sets", 0x80));
1130 cpu->addProp(new PromPropInt("i-cache-sets", 0x80));
1131 cpu->addProp(new PromPropInt("i-cache-block-size", 0x20));
1132 cpu->addProp(new PromPropInt("d-cache-block-size", 0x20));
1133 cpu->addProp(new PromPropString("graphics", ""));
1134 cpu->addProp(new PromPropString("performance-monitor", ""));
1135 cpu->addProp(new PromPropString("data-streams", ""));
1136
1137 PromNode *cache = new PromNode("cache");
1138 cpu->addProp(new PromPropInt("l2-cache", cache->getPHandle()));
1139 cache->addProp(new PromPropString("device_type", "cache"));
1140 cache->addProp(new PromPropInt("i-cache-size", 0x100000));
1141 cache->addProp(new PromPropInt("d-cache-size", 0x100000));
1142 cache->addProp(new PromPropInt("i-cache-sets", 0x2000));
1143 cache->addProp(new PromPropInt("d-cache-sets", 0x2000));
1144 cache->addProp(new PromPropInt("i-cache-line-size", 0x40));
1145 cache->addProp(new PromPropInt("d-cache-line-size", 0x40));
1146 // cache->addProp(new PromPropString("cache-unified", ""));
1147 cpu->addNode(cache);
1148
1149 gPromRoot->addNode(memory);
1150 gPromRoot->addNode(openprom);
1151 openprom->addProp(new PromPropString("model", "OpenFirmware3"));
1152 openprom->addProp(new PromPropString("relative-addressing", ""));
1153 gPromRoot->addNode(options);
1154 gPromRoot->addNode(packages);
1155 gPromRoot->addNode(pci);
1156 gPromRoot->addNodeShort("pci", "pci@80000000");
1157 gPromRoot->addNode(rom);
1158 gPromRoot->addNodeShort("rom", "rom@ff800000");
1159 byte regrom[] = {0xff,0x80,0x00,0x00, 0x00,0x00,0x00,0x00};
1160 rom->addProp(new PromPropMemory("reg", &regrom, sizeof regrom));
1161 byte rangesrom[] = {0xff,0x80,0x00,0x00, 0x00,0x80,0x00,0x00, 0xff,0x80,0x00,0x00};
1162 rom->addProp(new PromPropMemory("ranges", &rangesrom, sizeof rangesrom));
1163 rom->addProp(new PromPropInt("#address-cells", 1));
1164 PromNode *bootrom = new PromNode("boot-rom@fff00000");
1165 rom->addNode(bootrom);
1166 rom->addNodeShort("boot-rom", "boot-rom@fff00000");
1167 byte regbootrom[] = {0xff,0xf0,0x00,0x00, 0x00,0x10,0x00,0x00};
1168 bootrom->addProp(new PromPropMemory("reg", &regbootrom, sizeof regbootrom));
1169 bootrom->addProp(new PromPropString("write-characteristic", "flash"));
1170 // bootrom->addProp(new PromPropString("model", EMULATOR_MODEL" BootROM"));
1171 bootrom->addProp(new PromPropString("BootROM-version", "f2"));
1172 bootrom->addProp(new PromPropInt("result", 0));
1173 byte bootrominfo[] = {
1174 0xff,0xf0,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x01,0x12,0xf2,0x19,0x99,0x08,0x19,
1175 0x94,0x4e,0x73,0x27,0xff,0xf0,0x80,0x00,0x00,0x07,0x80,0x01,0x00,0x01,0x12,0xf2,
1176 0x19,0x99,0x08,0x19,0xd7,0xf3,0xfc,0x17,0xff,0xf8,0x00,0x00,0x00,0x08,0x00,0x02,
1177 0x00,0x01,0x12,0xf2,0x19,0x99,0x08,0x19,0xbb,0x10,0xfc,0x17};
1178 bootrom->addProp(new PromPropMemory("info", &bootrominfo, sizeof bootrominfo));
1179
1180 gPromRoot->addNode(rtas);
1181 gPromRoot->addNode(mmu);
1182 memory->addProp(new PromPropString("device_type", "memory"));
1183 uint32 memorySize = ppc_get_memory_size();
1184 byte reg[] = {0, 0, 0, 0, memorySize>>24, memorySize>>16, memorySize>>8, memorySize, 0, 0, 0, 0, 0, 0, 0, 0};
1185 memory->addProp(new PromPropMemory("reg", &reg, sizeof reg));
1186 byte av[] = {0, 0xa0, 0, 0, 1, 0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1187 memory->addProp(new PromPropMemory("available", &av, sizeof av));
1188 PromNode *pic = new PromNode("interrupt-controller@10");
1189 PromNode *bridge = new PromNode("pci-bridge@d");
1190 pci->addNode(bridge);
1191 pci->addNodeShort("pci-bridge", "pci-bridge@d");
1192 pci->addProp(new PromPropString("device_type", "pci"));
1193 pci->addProp(new PromPropString("model", "MOT,MPC106"));
1194 pci->addProp(new PromPropString("compatible", "grackle"));
1195 pci->addProp(new PromPropString("built-in", ""));
1196 pci->addProp(new PromPropString("used-by-rtas", ""));
1197 byte reg47[] = {0x80,0x00,0x00,0x00, 0x7f,0x00,0x00,0x00};
1198 pci->addProp(new PromPropMemory("reg", &reg47, sizeof reg47));
1199 pci->addProp(new PromPropInt("#address-cells", 3));
1200 pci->addProp(new PromPropInt("#interrupt-cells", 1));
1201 pci->addProp(new PromPropInt("#size-cells", 2));
1202 pci->addProp(new PromPropInt("clock-frequency", ppc_get_bus_frequency(0)));
1203 pci->addProp(new PromPropInt("bus-master-capable", 0x12000));
1204 byte ranges23[] = {
1205 0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xfe,0x00,0x00,0x00,
1206 0x00,0x00,0x00,0x00, 0x00,0x80,0x00,0x00, 0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1207 0x00,0x00,0x00,0x00, 0xfd,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x01,0x00,0x00,0x00,
1208 0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,
1209 0x00,0x00,0x00,0x00, 0x7d,0x00,0x00,0x00
1210 };
1211 pci->addProp(new PromPropMemory("ranges", &ranges23, sizeof ranges23));
1212 byte busranges23[] = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x01};
1213 pci->addProp(new PromPropMemory("bus-range", &busranges23, sizeof busranges23));
1214 byte interruptmap23[] = {
1215 // aty
1216 0x00,0x00,0x38,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1217 PHANDLE(pic), 0x00,0x00,0x00,IO_PIC_IRQ_GCARD};
1218 pci->addProp(new PromPropMemory("interrupt-map", &interruptmap23, sizeof interruptmap23));
1219 byte interruptmapmask23[] = {
1220 0x00,0x00,0xf8,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00};
1221 pci->addProp(new PromPropMemory("interrupt-map-mask", &interruptmapmask23, sizeof interruptmapmask23));
1222
1223 PromNode *macio = new PromNode("mac-io@5");
1224 bridge->addNode(macio);
1225 bridge->addNodeShort("macio", "mac-io@5");
1226 bridge->addProp(new PromPropInt("vendor-id", 0x1011));
1227 bridge->addProp(new PromPropInt("device-id", 0x0026));
1228 bridge->addProp(new PromPropInt("revision-id", 2));
1229 bridge->addProp(new PromPropInt("class-code", 0x60400));
1230 bridge->addProp(new PromPropInt("devsel-speed", 1));
1231 bridge->addProp(new PromPropString("fast-back-to-back", ""));
1232 bridge->addProp(new PromPropString("device_type", "pci"));
1233 byte reg5[] = {
1234 // bus dev
1235 0x00,0x00,0x68,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1236 0x00,0x00,0x00,0x00};
1237 bridge->addProp(new PromPropMemory("reg", &reg5, sizeof reg5));
1238 bridge->addProp(new PromPropInt("#address-cells", 3));
1239 bridge->addProp(new PromPropInt("#size-cells", 2));
1240 bridge->addProp(new PromPropInt("#interrupt-cells", 1));
1241 bridge->addProp(new PromPropInt("clock-frequency", ppc_get_bus_frequency(0)));
1242 bridge->addProp(new PromPropString("model", "DEC,21154"));
1243 bridge->addProp(new PromPropString("compatible", "DEC,21154.pci-bridge"));
1244 bridge->addProp(new PromPropInt("bus-master-capable", 0x7f));
1245 byte ranges22[] = {
1246 0x82,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x80,0x80,0x00,0x00,
1247 0x82,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x80,0x80,0x00,0x00,
1248 0x00,0x00,0x00,0x00, 0x00,0x20,0x00,0x00,
1249 0x81,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x10,0x00,
1250 0x81,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x10,0x00,
1251 0x00,0x00,0x00,0x00, 0x00,0x00,0x10,0x00};
1252 bridge->addProp(new PromPropMemory("ranges", &ranges22, sizeof ranges22));
1253
1254 // FIXME: why are not all devices described here? (e.g. gcard, cuda?)
1255 byte interruptmap22[] = {
1256 /* //
1257 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1258 PHANDLE(pic), 0x00,0x00,0x00,0x15,
1259 //
1260 0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1261 PHANDLE(pic), 0x00,0x00,0x00,0x17,*/
1262 // ide
1263 0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1264 PHANDLE(pic), 0x00,0x00,0x00,IO_PIC_IRQ_IDE0,
1265 // macio
1266 0x00,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1267 PHANDLE(pic), 0x00,0x00,0x00,0x18,
1268 // eth0
1269 0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1270 PHANDLE(pic), 0x00,0x00,0x00,IO_PIC_IRQ_ETHERNET0,
1271 // eth1
1272 0x00,0x00,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1273 PHANDLE(pic), 0x00,0x00,0x00,IO_PIC_IRQ_ETHERNET1,
1274 // usb
1275 0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1276 PHANDLE(pic), 0x00,0x00,0x00,IO_PIC_IRQ_USB
1277 };
1278
1279 bridge->addProp(new PromPropMemory("interrupt-map", &interruptmap22, sizeof interruptmap22));
1280 byte interruptmapmask22[] = {
1281 0x00,0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
1282 bridge->addProp(new PromPropMemory("interrupt-map-mask", &interruptmapmask22, sizeof interruptmapmask22));
1283
1284 PromNode *pci_ata = new PromNode("pci-ata@1");
1285 bridge->addNode(pci_ata);
1286 bridge->addNodeShort("pci-ata", "pci-ata@1");
1287 pci_ata->addProp(new PromPropInt("vendor-id", 0x1095));
1288 pci_ata->addProp(new PromPropInt("device-id", 0x0646));
1289 pci_ata->addProp(new PromPropInt("revision-id", 7));
1290 pci_ata->addProp(new PromPropInt("interrupts", 1));
1291 pci_ata->addProp(new PromPropInt("class-code", 0x1018f));
1292 pci_ata->addProp(new PromPropString("device_type", "pci-ide"));
1293 pci_ata->addProp(new PromPropInt("#address-cells", 1));
1294 pci_ata->addProp(new PromPropInt("#size-cells", 0));
1295 byte reg2010[] = {
1296 0x00,0x01,0x08,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1297 0x00,0x00,0x00,0x00,
1298 0x01,0x01,0x08,0x10, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1299 0x00,0x00,0x00,0x10,
1300 0x01,0x01,0x08,0x14, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1301 0x00,0x00,0x00,0x10,
1302 0x01,0x01,0x08,0x18, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1303 0x00,0x00,0x00,0x10,
1304 0x01,0x01,0x08,0x1c, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1305 0x00,0x00,0x00,0x10,
1306 0x01,0x01,0x08,0x20, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1307 0x00,0x00,0x00,0x10};
1308 pci_ata->addProp(new PromPropMemory("reg", &reg2010, sizeof reg2010));
1309 byte aa2010[] = {
1310 0x81,0x01,0x08,0x10, 0x00,0x00,0x00,0x00, 0x00,0x00,0x1c,0x40, 0x00,0x00,0x00,0x00,
1311 0x00,0x00,0x00,0x10,
1312 0x81,0x01,0x08,0x14, 0x00,0x00,0x00,0x00, 0x00,0x00,0x1c,0x30, 0x00,0x00,0x00,0x00,
1313 0x00,0x00,0x00,0x10,
1314 0x81,0x01,0x08,0x18, 0x00,0x00,0x00,0x00, 0x00,0x00,0x1c,0x20, 0x00,0x00,0x00,0x00,
1315 0x00,0x00,0x00,0x10,
1316 0x81,0x01,0x08,0x1c, 0x00,0x00,0x00,0x00, 0x00,0x00,0x1c,0x10, 0x00,0x00,0x00,0x00,
1317 0x00,0x00,0x00,0x10,
1318 0x81,0x01,0x08,0x20, 0x00,0x00,0x00,0x00, 0x00,0x00,0x1c,0x00, 0x00,0x00,0x00,0x00,
1319 0x00,0x00,0x00,0x10};
1320 pci_ata->addProp(new PromPropMemory("assigned-addresses", &aa2010, sizeof aa2010));
1321 IDEConfig *ic[2] = {ide_get_config(0), ide_get_config(1)};
1322 if (ic[0]->installed || ic[1]->installed) {
1323 PromNode *ata4 = new PromNode("ata-4");
1324 pci_ata->addNode(ata4);
1325 ata4->addProp(new PromPropString("device_type", "ata"));
1326 ata4->addProp(new PromPropInt("#address-cells", 1));
1327 ata4->addProp(new PromPropInt("#size-cells", 0));
1328 ata4->addProp(new PromPropInt("reg", 0));
1329 ata4->addProp(new PromPropString("compatible", "cmd646-ata"));
1330 if (ic[0]->installed) {
1331 PromNode *disk1 = new PromNodeDisk("disk0@0", 0);
1332 ata4->addNode(disk1);
1333 ata4->addNodeShort("disk", "disk0@0");
1334 ata4->addNodeShort("disk0", "disk0@0");
1335 disk1->addProp(new PromPropInt("device-id", 0));
1336 disk1->addProp(new PromPropInt("reg", 0));
1337 disk1->addProp(new PromPropString("device_type", "block"));
1338 disk1->addProp(new PromPropString("category", "hd"));
1339 }
1340 if (ic[1]->installed) {
1341 PromNode *disk2 = new PromNodeDisk("disk1@1", 1);
1342 ata4->addNode(disk2);
1343 ata4->addNodeShort("disk1", "disk1@1");
1344 disk2->addProp(new PromPropInt("device-id", 1));
1345 disk2->addProp(new PromPropInt("reg", 1));
1346 disk2->addProp(new PromPropString("device_type", "block"));
1347 disk2->addProp(new PromPropString("category", "hd"));
1348 }
1349 }
1350 macio->addProp(new PromPropString("device_type", "mac-io"));
1351 macio->addProp(new PromPropInt("vendor-id", 0x106b));
1352 macio->addProp(new PromPropInt("device-id", 0x0017));
1353 macio->addProp(new PromPropInt("revision-id", 0));
1354 macio->addProp(new PromPropInt("class-code", 0xff0000));
1355 macio->addProp(new PromPropString("model", "AAPL,343S1211"));
1356 macio->addProp(new PromPropMemory("compatible", "paddington\0heathrow", 19));
1357 byte reg4[] = {
1358 // bus dev
1359 0x00,0x01,0x28,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1360 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1361
1362 0x02,0x01,0x28,0x10, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1363 0x00,0x00,0x00,0x00, 0x00,0x08,0x00,0x00};
1364 macio->addProp(new PromPropMemory("reg", &reg4, sizeof reg4));
1365 byte aa2[] = {
1366 0x82,0x01,0x28,0x10, 0x00,0x00,0x00,0x00, 0x80,0x80,0x00,0x00, 0x00,0x00,0x00,0x00,
1367 0x00,0x08,0x00,0x00};
1368 macio->addProp(new PromPropMemory("assigned-addresses", &aa2, sizeof aa2));
1369 byte ranges2[] = {
1370 0x00,0x00,0x00,0x00,0x82,0x01,0x28,0x10,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,
1371 0x00,0x08,0x00,0x00};
1372 macio->addProp(new PromPropMemory("ranges", &ranges2, sizeof ranges2));
1373 macio->addProp(new PromPropInt("#address-cells", 1));
1374 macio->addProp(new PromPropInt("#size-cells", 1));
1375 /*
1376 PromNode *ata3 = new PromNode("ata-3");
1377 macio->addNode(ata3);
1378 ata3->addProp(new PromPropString("device_type", "ata"));
1379 ata3->addProp(new PromPropString("compatible", "heathrow-ata"));
1380 ata3->addProp(new PromPropInt("#address-cells", 1));
1381 ata3->addProp(new PromPropInt("#size-cells", 0));
1382 byte regata3[] = {
1383 0x00,0x02,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x8b,0x00,0x00,0x00,0x01,0x00};
1384 ata3->addProp(new PromPropMemory("reg", &regata3, sizeof regata3));
1385 byte interrupts2[] = {0, 0, 0, 0xd, 0, 0, 0, 2};
1386 ata3->addProp(new PromPropMemory("interrupts", &interrupts2, sizeof interrupts2));
1387 PromNode *disk2 = new PromNode("disk");
1388 ata3->addNode(disk2);
1389 disk2->addProp(new PromPropInt("device-id", 0));
1390 disk2->addProp(new PromPropInt("reg", 0));
1391 disk2->addProp(new PromPropString("device_type", "block"));
1392 disk2->addProp(new PromPropString("category", "hd"));
1393 */
1394 macio->addNode(pic);
1395 macio->addNodeShort("interrupt-controller", "interrupt-controller@10");
1396 pic->addProp(new PromPropString("device_type", "interrupt-controller"));
1397 pic->addProp(new PromPropMemory("compatible", "heathrow\0mac-risc\0", 18));
1398 byte reg2[] = {0, 0, 0, 0x10, 0, 0, 0, 0x20};
1399 pic->addProp(new PromPropMemory("reg", &reg2, sizeof reg2));
1400 pic->addProp(new PromPropInt("#interrupt-cells", 1));
1401 pic->addProp(new PromPropString("interrupt-controller", ""));
1402 PromNode *via = new PromNode("via-cuda@16000");
1403 macio->addNode(via);
1404 macio->addNodeShort("via-cuda", "via-cuda@16000");
1405 PromNode *adb = new PromNode("adb");
1406 via->addNode(adb);
1407 adb->addProp(new PromPropString("device_type", "adb"));
1408 PromNode *keyboard = new PromNode("keyboard");
1409 adb->addNode(keyboard);
1410 keyboard->addProp(new PromPropString("device_type", "keyboard"));
1411 PromNode *mouse = new PromNode("mouse");
1412 adb->addNode(mouse);
1413 mouse->addProp(new PromPropString("device_type", "mouse"));
1414 mouse->addProp(new PromPropInt("#buttons", 3));
1415 mouse->addProp(new PromPropInt("reg", 3));
1416 // byte regmouse[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0};
1417 // mouse->addProp(new PromPropMemory("reg", &regmouse, sizeof regmouse));
1418 via->addProp(new PromPropString("compatible", "cuda"));
1419 via->addProp(new PromPropString("device_type", "via-cuda"));
1420
1421 byte reg3[] = {0x00,0x01,0x60,0x00, 0x00,0x00,0x20,0x00};
1422 via->addProp(new PromPropMemory("reg", &reg3, sizeof reg3));
1423
1424 via->addProp(new PromPropInt("interrupts", 0x12));
1425 via->addProp(new PromPropLink("interrupt-parent", pic->getPHandle()));
1426 PromNode *rtc = new PromNode("rtc");
1427 via->addNode(rtc);
1428 rtc->addProp(new PromPropString("device_type", "rtc"));
1429 PromNode *nvram = new PromNode("nvram@60000");
1430 macio->addNode(nvram);
1431 macio->addNodeShort("nvram", "nvram@60000");
1432 nvram->addProp(new PromPropString("device_type", "nvram"));
1433 byte regnv[] = {0x00,0x06,0x00,0x00,0x00,0x02,0x00,0x00};
1434 nvram->addProp(new PromPropMemory("reg", &regnv, sizeof regnv));
1435 nvram->addProp(new PromPropInt("#bytes", 0x2000));
1436 PromNode *powermgt = new PromNode("power-mgt");
1437 macio->addNode(powermgt);
1438 powermgt->addProp(new PromPropString("device_type", "power-mgt"));
1439 powermgt->addProp(new PromPropString("compatible", "cuda"));
1440 powermgt->addProp(new PromPropString("mgt-kind", "min-consumption-pwm-led"));
1441 byte regmgt[] = {
1442 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00};
1443 powermgt->addProp(new PromPropMemory("reg", &regmgt, sizeof regmgt));
1444
1445 /*
1446 * Eth0
1447 */
1448 if (_3c90x_installed) {
1449 PromNode *eth0 = new PromNode("pci10b7,9200@4");
1450 bridge->addNode(eth0);
1451 bridge->addNodeShort("pci10b7,9200", "pci10b7,9200@4");
1452 eth0->addProp(new PromPropMemory("compatible",
1453 "pci10b7,9200\x00pciclass,020000\x00", 29));
1454 // eth0->addProp(new PromPropString("device_type", "network"));
1455 eth0->addProp(new PromPropInt("vendor-id", 0x10b7));
1456 eth0->addProp(new PromPropInt("device-id", 0x9200));
1457 eth0->addProp(new PromPropInt("revision-id", 0x0));
1458 eth0->addProp(new PromPropInt("class-code", 0x020000));
1459 eth0->addProp(new PromPropInt("interrupts", 1));
1460 eth0->addProp(new PromPropInt("min-grant", 0));
1461 eth0->addProp(new PromPropInt("max-latency", 0));
1462 eth0->addProp(new PromPropInt("subsystem-vendor-id", 0x10b7));
1463 eth0->addProp(new PromPropInt("subsystem-id", 0x9200));
1464 eth0->addProp(new PromPropInt("devsel-speed", 1));
1465 eth0->addProp(new PromPropString("fast-back-to-back", ""));
1466
1467 byte eth0reg[] = {
1468 0x00,0x01,0x60,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1469 0x00,0x00,0x00,0x00,
1470 0x01,0x01,0x60,0x10, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1471 0x00,0x00,0x01,0x00,
1472 };
1473 eth0->addProp(new PromPropMemory("reg", &eth0reg, sizeof eth0reg));
1474
1475 byte eth0aa[] = {
1476 0x81,0x01,0x60,0x10,
1477 0x00,0x00,0x00,0x00,
1478 /* 4 bytes address from 3c90x/3c90x.cc: */ 0x00,0x00,0x10,0x00,
1479 0x00,0x00,0x00,0x00,
1480 0x00,0x00,0x01,0x00,
1481 };
1482 eth0->addProp(new PromPropMemory("assigned-addresses", &eth0aa, sizeof eth0aa));
1483 }
1484
1485 /*
1486 * Eth1
1487 */
1488 if (rtl8139_installed) {
1489 PromNode *eth1 = new PromNode("pci10ec,8139@4");
1490 bridge->addNode(eth1);
1491 bridge->addNodeShort("pci10ec,8139", "pci10ec,8139@4");
1492 eth1->addProp(new PromPropMemory("compatible",
1493 "pci10ec,8139\x00pciclass,020000\x00", 29));
1494 // eth1->addProp(new PromPropString("device_type", "network"));
1495 eth1->addProp(new PromPropInt("vendor-id", 0x10ec));
1496 eth1->addProp(new PromPropInt("device-id", 0x8139));
1497 eth1->addProp(new PromPropInt("revision-id", 0x0));
1498 eth1->addProp(new PromPropInt("class-code", 0x020000));
1499 eth1->addProp(new PromPropInt("interrupts", 1));
1500 eth1->addProp(new PromPropInt("min-grant", 0));
1501 eth1->addProp(new PromPropInt("max-latency", 0));
1502 eth1->addProp(new PromPropInt("subsystem-vendor-id", 0x10ec));
1503 eth1->addProp(new PromPropInt("subsystem-id", 0x8139));
1504 eth1->addProp(new PromPropInt("devsel-speed", 1));
1505 eth1->addProp(new PromPropString("fast-back-to-back", ""));
1506
1507 byte eth1reg[] = {
1508 0x00,0x01,0x68,0x00,
1509 0x00,0x00,0x00,0x00,
1510 0x00,0x00,0x00,0x00,
1511 0x00,0x00,0x00,0x00,
1512 0x00,0x00,0x00,0x00,
1513
1514 0x01,0x01,0x68,0x10,
1515 0x00,0x00,0x00,0x00,
1516 0x00,0x00,0x00,0x00,
1517 0x00,0x00,0x00,0x00,
1518 0x00,0x00,0x01,0x00,
1519 };
1520 eth1->addProp(new PromPropMemory("reg", &eth1reg, sizeof eth1reg));
1521
1522 byte eth1aa[] = {
1523 0x81,0x01,0x68,0x10,
1524 0x00,0x00,0x00,0x00,
1525 /* 4 bytes address from rtl8139/rtl8139.cc: */ 0x00,0x00,0x18,0x00,
1526 0x00,0x00,0x00,0x00,
1527 0x00,0x00,0x01,0x00,
1528 };
1529 eth1->addProp(new PromPropMemory("assigned-addresses", &eth1aa, sizeof eth1aa));
1530 }
1531
1532 /*
1533 * USB
1534 */
1535 PromNode *usb = new PromNode("usb@6");
1536 bridge->addNode(usb);
1537 bridge->addNodeShort("usb", "usb@6");
1538 usb->addProp(new PromPropInt("vendor-id", 0x1045));
1539 usb->addProp(new PromPropInt("device-id", 0xc861));
1540 usb->addProp(new PromPropInt("revision-id", 0x10));
1541 usb->addProp(new PromPropInt("class-code", 0x0c0310));
1542 usb->addProp(new PromPropInt("interrupts", 1));
1543 usb->addProp(new PromPropInt("min-grant", 0));
1544 usb->addProp(new PromPropInt("max-latency", 0));
1545 usb->addProp(new PromPropInt("subsystem-vendor-id", 0x1045));
1546 usb->addProp(new PromPropInt("subsystem-id", 0xc861));
1547 usb->addProp(new PromPropInt("devsel-speed", 1));
1548 usb->addProp(new PromPropString("fast-back-to-back", ""));
1549 usb->addProp(new PromPropString("device_type", "usb"));
1550 byte usbreg[] = {
1551 0x00,0x01,0x30,0x00,
1552 0x00,0x00,0x00,0x00,
1553 0x00,0x00,0x00,0x00,
1554 0x00,0x00,0x00,0x00,
1555 0x00,0x00,0x00,0x00,
1556
1557 0x02,0x01,0x30,0x10,
1558 0x00,0x00,0x00,0x00,
1559 0x00,0x00,0x00,0x00,
1560 0x00,0x00,0x00,0x00,
1561 0x00,0x00,0x10,0x00
1562 };
1563
1564 usb->addProp(new PromPropMemory("reg", &usbreg, sizeof usbreg));
1565 byte usbaa[] = {
1566 0x82,0x01,0x30,0x10, 0x00,0x00,0x00,0x00,
1567 /* 4 bytes address from usb/usb.c:*/ 0x80,0x88,0x10,0x00,
1568 0x00,0x00,0x00,0x00, 0x00,0x00,0x10,0x00};
1569
1570 usb->addProp(new PromPropInt("#address-cells", 1));
1571 usb->addProp(new PromPropInt("#size-cells", 0));
1572 usb->addProp(new PromPropMemory("compatible",
1573 "pci1045,c861\x00pciclass,0c0310\x00", 29));
1574 usb->addProp(new PromPropMemory("assigned-addresses", &usbaa, sizeof usbaa));
1575
1576 PromNode *usbhub = new PromNode("hub@1");
1577 usb->addNode(usbhub);
1578 usb->addNodeShort("hub", "hub@1");
1579 usbhub->addProp(new PromPropInt("assigned-addresses", 1));
1580 usbhub->addProp(new PromPropString("device_type", "hub"));
1581 usbhub->addProp(new PromPropInt("#address-cells", 1));
1582 usbhub->addProp(new PromPropInt("#size-cells", 0));
1583
1584 /*
1585 * Video
1586 */
1587 PromNode *aty = new PromNodeATY("PearPCVideo");
1588 pci->addNode(aty);
1589 // aty->addProp(new PromPropInt("vendor-id", 0x1002));
1590 // aty->addProp(new PromPropInt("device-id", 0x5245));
1591 // aty->addProp(new PromPropInt("revision-id", 0));
1592 aty->addProp(new PromPropInt("interrupts", 1));
1593 aty->addProp(new PromPropInt("mol-irq", IO_PIC_IRQ_GCARD));
1594 aty->addProp(new PromPropInt("vendor-id", 0x6666));
1595 aty->addProp(new PromPropInt("device-id", 0x6666));
1596 aty->addProp(new PromPropInt("revision-id", 0x0));
1597 aty->addProp(new PromPropInt("class-code", 0x30000));
1598 aty->addProp(new PromPropString("device_type", "display"));
1599 aty->addProp(new PromPropString("model", "PearPC,display"));
1600 aty->addProp(new PromPropString("Ignore VBL", "yes"));
1601 aty->addProp(new PromPropInt("width", gDisplay->mClientChar.width));
1602 aty->addProp(new PromPropInt("height", gDisplay->mClientChar.height));
1603 aty->addProp(new PromPropInt("depth", gDisplay->mClientChar.bytesPerPixel * 8));
1604 aty->addProp(new PromPropInt("linebytes", gDisplay->mClientChar.width * gDisplay->mClientChar.bytesPerPixel));
1605 aty->addProp(new PromPropString("character-set", "ISO8859-1"));
1606 /*
1607 byte atyreg[] = {
1608 0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1609 0x00,0x00,0x00,0x00,0x02,0x00,0x80,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1610 0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x42,0x00,0x80,0x10,0x00,0x00,0x00,0x00,
1611 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x80,0x18,
1612 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,
1613 };
1614 aty->addProp(new PromPropMemory("reg", &atyreg, sizeof atyreg));
1615 byte assigned_addresses[] = {
1616 0xc2,0x00,0x80,0x10, 0x00,0x00,0x00,0x00, 0x84,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1617 0x04,0x00,0x00,0x00, 0x82,0x00,0x80,0x30, 0x00,0x00,0x00,0x00, 0x80,0xa2,0x00,0x00,
1618 0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x00, 0x82,0x00,0x80,0x18, 0x00,0x00,0x00,0x00,
1619 0x80,0xa0,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x40,0x00};
1620 aty->addProp(new PromPropMemory("assigned-addresses", &assigned_addresses, sizeof assigned_addresses));
1621 */
1622 aty->addProp(new PromPropInt("address", IO_GCARD_FRAMEBUFFER_PA_START));
1623 byte atyreg[] = {
1624 0x00,0x00,0x38,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1625 0x00,0x00,0x00,0x00,
1626 0x02,0x00,0x38,0x10, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1627 0x01,0x00,0x00,0x00,
1628 };
1629 aty->addProp(new PromPropMemory("reg", &atyreg, sizeof atyreg));
1630 byte assigned_addresses[] = {
1631 0x82,0x00,0x38,0x10, 0x00,0x00,0x00,0x00, UINT32(IO_GCARD_FRAMEBUFFER_PA_START),
1632 0x00,0x00,0x00,0x00, 0x01,0x00,0x00,0x00,
1633 };
1634 aty->addProp(new PromPropMemory("assigned-addresses", &assigned_addresses, sizeof assigned_addresses));
1635
1636 aliases->addProp(new PromPropString("pci", "/pci"));
1637 aliases->addProp(new PromPropString("bridge", "/pci/pci-bridge"));
1638 aliases->addProp(new PromPropString("macio", "/pci/pci-bridge/macio"));
1639 aliases->addProp(new PromPropString("screen", "/pci@80000000/PearPCVideo"));
1640 int cdromcount=0, hdcount=0;
1641 for (int i=0; i<2; i++) {
1642 if (ic[i]->installed) {
1643 String alias, location;
1644 if (ic[i]->protocol == IDE_ATA) {
1645 alias.assignFormat("disk%d", hdcount);
1646 location.assignFormat("/pci/pci-bridge/pci-ata/ata-4/disk%d@%d", i, i);
1647 aliases->addProp(new PromPropString(alias.contentChar(), location.contentChar()));
1648 if (!hdcount) {
1649 aliases->addProp(new PromPropString("disk", location.contentChar()));
1650 aliases->addProp(new PromPropString("hd", location.contentChar()));
1651 }
1652 hdcount++;
1653 } else {
1654 alias.assignFormat("cdrom%d", cdromcount);
1655 location.assignFormat("/pci/pci-bridge/pci-ata/ata-4/disk%d@%d", i, i);
1656 aliases->addProp(new PromPropString(alias.contentChar(), location.contentChar()));
1657 if (!cdromcount) {
1658 aliases->addProp(new PromPropString("cdrom", location.contentChar()));
1659 aliases->addProp(new PromPropString("cd", location.contentChar()));
1660 }
1661 cdromcount++;
1662 }
1663 }
1664 }
1665 // insert links
1666 // chosen->addProp(new PromPropString("bootpath", "cd:,ofwboot"));
1667 // chosen->addProp(new PromPropString("bootpath", "disk:,ofwboot"));
1668 // chosen->addProp(new PromPropString("bootargs", "ide=nodma root=/dev/hda1"));
1669 // chosen->addProp(new PromPropString("bootargs", "/3.4/macppc/bsd.rd"));
1670
1671 PromInstanceHandle pih = mmu->open("");
1672 chosen->addProp(new PromPropLink("mmu", pih));
1673 pih = aty->open("");
1674 chosen->addProp(new PromPropLink("stdout", pih));
1675 pih = kbd->open("");
1676 chosen->addProp(new PromPropLink("stdin", pih));
1677 pih = memory->open("");
1678 chosen->addProp(new PromPropLink("memory", pih));
1679 }
1680
1681 void prom_done_device_tree()
1682 {
1683 if (gPromRoot) {
1684 delete gPromRoot;
1685 gPromRoot = NULL;
1686 }
1687 }

  ViewVC Help
Powered by ViewVC 1.1.26