ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/AmigaOS/sys_amiga.cpp
(Generate patch)

Comparing BasiliskII/src/AmigaOS/sys_amiga.cpp (file contents):
Revision 1.7 by cebix, 2002-01-15T14:58:34Z vs.
Revision 1.8 by jlachmann, 2002-06-23T08:27:05Z

# Line 1 | Line 1
1   /*
2   *  sys_amiga.cpp - System dependent routines, Amiga implementation
3   *
4 < *  Basilisk II (C) 1997-2002 Christian Bauer
4 > *  Basilisk II (C) 1997-2001 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 24 | Line 24
24   #include <devices/trackdisk.h>
25   #include <devices/scsidisk.h>
26   #include <resources/disk.h>
27 + #define __USE_SYSBASE
28   #include <proto/dos.h>
29   #include <proto/exec.h>
30   #include <proto/disk.h>
31 + #include <inline/dos.h>
32 + #include <inline/exec.h>
33 + #include <inline/disk.h>
34  
35   #include "sysdeps.h"
36   #include "main.h"
# Line 212 | Line 216 | void *Sys_open(const char *name, bool re
216                          return NULL;
217  
218                  // Open device
219 <                if (OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)io, dev_flags)) {
219 >                if (OpenDevice((UBYTE *) dev_name, dev_unit, (struct IORequest *)io, dev_flags)) {
220                          D(bug(" couldn't open device\n"));
221                          DeleteIORequest(io);
222                          return NULL;
# Line 381 | Line 385 | static loff_t send_io_request(file_handl
385  
386          } else {
387  
388 <                if (DoIO((struct IORequest *)fh->io) || fh->io->io_Actual != length)
388 > //              if (DoIO((struct IORequest *)fh->io) || fh->io->io_Actual != length)
389 >                if (DoIO((struct IORequest *)fh->io))
390 >                        {
391 >                        D(bug("send_io_request/%ld: Actual=%lu  length=%lu  Err=%ld\n", __LINE__, fh->io->io_Actual, length, fh->io->io_Error));
392                          return 0;
393 +                        }
394                  return fh->io->io_Actual;
395          }
396   }
# Line 397 | Line 405 | size_t Sys_read(void *arg, void *buffer,
405   {
406          file_handle *fh = (file_handle *)arg;
407          if (!fh)
408 +                {
409 +                D(bug("Sys_read/%ld return 0\n", __LINE__));
410                  return 0;
411 +                }
412 +
413 +        D(bug("Sys_read/%ld length=%ld\n", __LINE__, length));
414  
415          // File or device?
416          if (fh->is_file) {
417  
418                  // File, seek to position
419                  if (Seek(fh->f, offset + fh->start_byte, OFFSET_BEGINNING) == -1)
420 +                        {
421 +                        D(bug("Sys_read/%ld return 0\n", __LINE__));
422                          return 0;
423 +                        }
424  
425                  // Read data
426                  LONG actual = Read(fh->f, buffer, length);
427                  if (actual == -1)
428 +                        {
429 +                        D(bug("Sys_read/%ld return 0\n", __LINE__));
430                          return 0;
431 +                        }
432                  else
433 +                        {
434 +                        D(bug("Sys_read/%ld return %ld\n", __LINE__, actual));
435                          return actual;
436 +                        }
437  
438          } else {
439  
# Line 423 | Line 445 | size_t Sys_read(void *arg, void *buffer,
445  
446                          // Yes, read one block
447                          if (send_io_request(fh, false, fh->block_size, pos - pre_offset, tmp_buf) == 0)
448 +                                {
449 +                                D(bug("Sys_read/%ld return %ld\n", __LINE__, 0));
450                                  return 0;
451 +                                }
452  
453                          // Copy data to destination buffer
454                          size_t pre_length = fh->block_size - pre_offset;
# Line 444 | Line 469 | size_t Sys_read(void *arg, void *buffer,
469                          // Yes, read blocks
470                          size_t main_length = length & ~(fh->block_size - 1);
471                          if (send_io_request(fh, false, main_length, pos, buffer) == 0)
472 +                                {
473 +                                D(bug("Sys_read/%ld return %ld\n", __LINE__, 0));
474                                  return 0;
475 +                                }
476  
477                          // Adjust data pointers
478                          buffer = (uint8 *)buffer + main_length;
# Line 458 | Line 486 | size_t Sys_read(void *arg, void *buffer,
486  
487                          // Yes, read one block
488                          if (send_io_request(fh, false, fh->block_size, pos, tmp_buf) == 0)
489 +                                {
490 +                                D(bug("Sys_read/%ld return %ld\n", __LINE__, 0));
491                                  return 0;
492 +                                }
493  
494                          // Copy data to destination buffer
495                          memcpy(buffer, tmp_buf, length);
496                          actual += length;
497                  }
498  
499 +                D(bug("Sys_read/%ld return %ld\n", __LINE__, actual));
500                  return actual;
501          }
502   }
# Line 479 | Line 511 | size_t Sys_write(void *arg, void *buffer
511   {
512          file_handle *fh = (file_handle *)arg;
513          if (!fh)
514 +                {
515 +                D(bug("Sys_write/%ld return %ld\n", __LINE__, 0));
516                  return 0;
517 +                }
518 +
519 +        D(bug("Sys_write/%ld length=%ld\n", __LINE__, length));
520  
521          // File or device?
522          if (fh->is_file) {
523  
524                  // File, seek to position if necessary
525                  if (Seek(fh->f, offset + fh->start_byte, OFFSET_BEGINNING) == -1)
526 +                        {
527 +                        D(bug("Sys_write/%ld return %ld\n", __LINE__, 0));
528                          return 0;
529 +                        }
530  
531                  // Write data
532                  LONG actual = Write(fh->f, buffer, length);
533                  if (actual == -1)
534 +                        {
535 +                        D(bug("Sys_write/%ld return %ld\n", __LINE__, 0));
536                          return 0;
537 +                        }
538                  else
539 +                        {
540 +                        D(bug("Sys_write/%ld return %ld\n", __LINE__, actual));
541                          return actual;
542 +                        }
543  
544          } else {
545  
# Line 505 | Line 551 | size_t Sys_write(void *arg, void *buffer
551  
552                          // Yes, read one block
553                          if (send_io_request(fh, false, fh->block_size, pos - pre_offset, tmp_buf) == 0)
554 +                                {
555 +                                D(bug("Sys_write/%ld return %ld\n", __LINE__, 0));
556                                  return 0;
557 +                                }
558  
559                          // Copy data from source buffer
560                          size_t pre_length = fh->block_size - pre_offset;
# Line 515 | Line 564 | size_t Sys_write(void *arg, void *buffer
564  
565                          // Write block back
566                          if (send_io_request(fh, true, fh->block_size, pos - pre_offset, tmp_buf) == 0)
567 +                                {
568 +                                D(bug("Sys_write/%ld return %ld\n", __LINE__, 0));
569                                  return 0;
570 +                                }
571  
572                          // Adjust data pointers
573                          buffer = (uint8 *)buffer + pre_length;
# Line 530 | Line 582 | size_t Sys_write(void *arg, void *buffer
582                          // Yes, write blocks
583                          size_t main_length = length & ~(fh->block_size - 1);
584                          if (send_io_request(fh, true, main_length, pos, buffer) == 0)
585 +                                {
586 +                                D(bug("Sys_write/%ld return %ld\n", __LINE__, 0));
587                                  return 0;
588 +                                }
589  
590                          // Adjust data pointers
591                          buffer = (uint8 *)buffer + main_length;
# Line 544 | Line 599 | size_t Sys_write(void *arg, void *buffer
599  
600                          // Yes, read one block
601                          if (send_io_request(fh, false, fh->block_size, pos, tmp_buf) == 0)
602 +                                {
603 +                                D(bug("Sys_write/%ld return %ld\n", __LINE__, 0));
604                                  return 0;
605 +                                }
606  
607                          // Copy data from source buffer
608                          memcpy(buffer, tmp_buf, length);
609  
610                          // Write block back
611                          if (send_io_request(fh, true, fh->block_size, pos, tmp_buf) == 0)
612 +                                {
613 +                                D(bug("Sys_write/%ld return %ld\n", __LINE__, 0));
614                                  return 0;
615 +                                }
616                          actual += length;
617                  }
618  
619 +                D(bug("Sys_write/%ld return %ld\n", __LINE__, actual));
620                  return actual;
621          }
622   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines