Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/sysprogs/iotest.c need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #include "stdio.h"
0019 
0020 #define NUM_THREADS 4
0021 #define USB
0022 #define USB_FILE "(usb)/test"
0023 #define CDROM
0024 #define CDROM_FILE "(cd)/gpxe.krn"
0025 //#define CDROM_FILE "(cd)/boot/quest"
0026 
0027 char buf[65536];
0028 void *memset( void *p, int ch, size_t cb );
0029 
0030 void
0031 child (int idx)
0032 {
0033   unsigned long i = 0, j;
0034   char ch;
0035   if (idx <= 9)
0036     ch = idx + '0';
0037   else
0038     ch = (idx - 10) + 'A';
0039   for (;;) {
0040     if (!(i & 0xFFFFF)) {
0041       memset (buf, ch, sizeof (buf));
0042       if (idx == 0) {
0043 #ifdef USB
0044         open (USB_FILE, 0);
0045         read (USB_FILE, buf, sizeof (buf));
0046         for (j=0; j<sizeof (buf)-1; j++)
0047           if (buf[j] != 'a')
0048             printf ("buf[%d] == 'a'\n", j, buf[j]);
0049 #endif
0050         putchar (buf[0]);
0051       } else if (idx == 1) {
0052 #ifdef CDROM
0053         unsigned long sum = 0;
0054         open (CDROM_FILE, 0);
0055         read (CDROM_FILE, buf, sizeof (buf));
0056         printf ("%x", buf[0x21] & 0xFF);
0057         for (j=0; j<sizeof (buf); j++)
0058           sum += (unsigned char) buf[j];
0059 #else
0060         putchar (buf[0]);
0061 #endif
0062       } else {
0063         putchar (buf[0]);
0064       }
0065     }
0066     i++;
0067   }
0068 }
0069 
0070 int
0071 main (void)
0072 {
0073   int pid[NUM_THREADS];
0074   int i;
0075 
0076   for (i=1; i<NUM_THREADS; i++) {
0077     if ((pid[i]=fork ()) == 0) {
0078       child (i);
0079     }
0080   }
0081 
0082   child (0);
0083   return 0;
0084 }
0085 
0086 /*
0087  * Local Variables:
0088  * indent-tabs-mode: nil
0089  * mode: C
0090  * c-file-style: "gnu"
0091  * c-basic-offset: 2
0092  * End:
0093  */
0094 
0095 /* vi: set et sw=2 sts=2: */