dummy.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * This is a set of functions that provides access to a Linux kernel
  3. * starting at sector BOOT_SECT+aboot_size/SECT_SIZE
  4. *
  5. * Michael Schwingen (rincewind@discworld.oche.de).
  6. */
  7. #include "system.h"
  8. #include <config.h>
  9. #include <aboot.h>
  10. #include <bootfs.h>
  11. #include <cons.h>
  12. #include <utils.h>
  13. #define BLOCKSIZE (16*SECT_SIZE)
  14. static int dummy_mount(long cons_dev, long p_offset, long quiet);
  15. static int dummy_bread(int fd, long blkno, long nblks, char *buffer);
  16. static int dummy_open(const char *filename);
  17. static void dummy_close(int fd);
  18. struct bootfs dummyfs = {
  19. 0, BLOCKSIZE,
  20. dummy_mount,
  21. dummy_open, dummy_bread, dummy_close
  22. };
  23. static long dev = -1;
  24. /*
  25. * Initialize 'filesystem'
  26. * Returns 0 if successful, -1 on failure.
  27. */
  28. static int
  29. dummy_mount(long cons_dev, long p_offset, long quiet)
  30. {
  31. dev = cons_dev;
  32. return 0;
  33. }
  34. /*
  35. * Read block number "blkno".
  36. */
  37. static int
  38. dummy_bread(int fd, long blkno, long nblks, char *buffer)
  39. {
  40. extern char _end;
  41. static long aboot_size = 0;
  42. if (!aboot_size) {
  43. aboot_size = &_end - (char *) BOOT_ADDR + SECT_SIZE - 1;
  44. aboot_size &= ~(SECT_SIZE - 1);
  45. }
  46. if (cons_read(dev, buffer, nblks*BLOCKSIZE,
  47. BOOT_SECTOR*SECT_SIZE + blkno*BLOCKSIZE + aboot_size)
  48. != nblks*BLOCKSIZE)
  49. {
  50. printf("dummy_bread: read error\n");
  51. return -1;
  52. }
  53. return nblks*BLOCKSIZE;
  54. }
  55. /*
  56. * Unix-like open routine. Returns a small integer
  57. * (does not care what file, we say it's OK)
  58. */
  59. static int dummy_open(const char *filename)
  60. {
  61. return 1;
  62. }
  63. static void dummy_close(int fd)
  64. {
  65. }