示例#1
0
int start4(char *arg)
{
    int result;
    int status;

    USLOSS_Console("start4(): Writing data to 3 disk sectors, wrapping ");
    USLOSS_Console("to next track\n");

    USLOSS_Console("\nstart4(): Disk 0:\n");
    strcpy(&sectors[0 * 512], "This is a test\n");
    strcpy(&sectors[1 * 512], "Does it work?\n");
    strcpy(&sectors[2 * 512], "One last chance\n");
    result = DiskWrite((char *) sectors, 0, 4, 15, 3, &status);
    assert(result == 0);
    result = DiskRead((char *) copy, 0, 4, 15, 3, &status);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[0*512]);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[1*512]);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[2*512]);

    USLOSS_Console("\nstart4(): Disk 1:\n");
    strcpy(&sectors[0 * 512], "This is a test\n");
    strcpy(&sectors[1 * 512], "Does it work?\n");
    strcpy(&sectors[2 * 512], "One last chance\n");
    result = DiskWrite((char *) sectors, 1, 4, 15, 3, &status);
    assert(result == 0);
    result = DiskRead((char *) copy, 1, 4, 15, 3, &status);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[0*512]);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[1*512]);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[2*512]);

    Terminate(24);
    return 0;
}
示例#2
0
int start4(char *arg)
{
    int result;
    int status;
    int i;
    int failed;

    for ( i = 0; i < 512 * 3; i++ ) {
        sectors[i] = ((i % 13) * 3456);
    }
    USLOSS_Console("start4(): Writing data to 3 disk sectors, then reading them back\n");
    USLOSS_Console("          Confirm that data read back matches data read in\n");

    USLOSS_Console("start4(): Testing Disk 0\n");
    failed = 0;
    result = DiskWrite((char *) sectors, 0, 4, 2, 3, &status);
    assert(result == 0);
    assert(status == 0);
    result = DiskRead((char *) copy, 0, 4, 2, 3, &status);
    for ( i = 0; i < 512 * 3; i++ ) {
        if (copy[i]!=sectors[i]) {
            USLOSS_Console("start4(): Buffer read back fm disk 0 invalid at byte %d\n", i);
            failed = 1;
            break;
        }
    }
    if ( ! failed )
        USLOSS_Console("start4(): Test of disk 0 succeeded.\n");

   USLOSS_Console("start4(): Testing Disk 1\n");
   failed = 0;
   result = DiskWrite((char *) sectors, 1, 4, 2, 3, &status);
   assert(result == 0);
   assert(status == 0);
   result = DiskRead((char *) copy, 1, 4, 2, 3, &status);
   for ( i = 0; i < 512 * 3; i++ ) {
       if ( copy[i]!=sectors[i] ) {
           USLOSS_Console("start4(): Buffer read back fm disk 1 invalid at byte %d\n", i);
         failed = 1;
         break;
       }
    }
    if ( ! failed )
        USLOSS_Console("start4(): Test of disk 1 succeeded.\n");

    USLOSS_Console("start4(): Done.\n");

    Terminate(24);
    return 0;
} /* start4 */
示例#3
0
int ChildDW0(char *arg)
{
   int status;
   char disk_buf_A[512];

   USLOSS_Console("\nChildDW0(): writing to disk 0, track 5, sector 0\n");
   sprintf(disk_buf_A, "ChildDW0(): A wonderful message to put on the disk...");
   DiskWrite(disk_buf_A, 0, 5, 0, 1, &status);
   USLOSS_Console("ChildDW0(): DiskWrite0 returned status = %d\n", status);
   return 0;
} /* ChildDW0 */
示例#4
0
/** @brief Write sectors to a physical block device.

    The behavior of calling this function is undefined if the block device is
    closed or if it was opened with ::BDEV_O_RDONLY.

    @param bVolNum          The volume number of the volume whose block device
                            is being written to.
    @param ullSectorStart   The starting sector number.
    @param ulSectorCount    The number of sectors to write.
    @param pBuffer          The buffer from which to write the sector data.

    @return A negated ::REDSTATUS code indicating the operation result.

    @retval 0           Operation was successful.
    @retval -RED_EINVAL @p bVolNum is an invalid volume number, @p pBuffer is
                        `NULL`, or @p ullStartSector and/or @p ulSectorCount
                        refer to an invalid range of sectors.
    @retval -RED_EIO    A disk I/O error occurred.
*/
REDSTATUS RedOsBDevWrite(
    uint8_t     bVolNum,
    uint64_t    ullSectorStart,
    uint32_t    ulSectorCount,
    const void *pBuffer)
{
    REDSTATUS   ret = 0;

    if(    (bVolNum >= REDCONF_VOLUME_COUNT)
            || (ullSectorStart >= gaRedVolConf[bVolNum].ullSectorCount)
            || ((gaRedVolConf[bVolNum].ullSectorCount - ullSectorStart) < ulSectorCount)
            || (pBuffer == NULL)) {
        ret = -RED_EINVAL;
    } else {
        ret = DiskWrite(bVolNum, ullSectorStart, ulSectorCount, pBuffer);
    }

    return ret;
}
示例#5
0
int start4(char *arg)
{
    int unit, sectorSize, trackSize, diskSize;
    char disk_buf_A[512];
    char disk_buf_B[512];
    int status;

    USLOSS_Console("start4(): started\n");

    unit = 0;
    DiskSize(unit, &sectorSize, &trackSize, &diskSize);

    USLOSS_Console("start4(): ");
    USLOSS_Console("unit %d, sector size %d, track size %d, disk size %d\n",
           unit, sectorSize, trackSize, diskSize);

    unit = 1;
    DiskSize(unit, &sectorSize, &trackSize, &diskSize);

    USLOSS_Console("start4(): ");
    USLOSS_Console("unit %d, sector size %d, track size %d, disk size %d\n",
           unit, sectorSize, trackSize, diskSize);

    USLOSS_Console("\nstart4(): writing to disk 0, track 5, sector 0\n");
    sprintf(disk_buf_A, "A wonderful message to put on the disk...");
    DiskWrite(disk_buf_A, 0, 5, 0, 1, &status);
    USLOSS_Console("start4(): DiskWrite returned status = %d\n", status);

    USLOSS_Console("\nstart4(): reading from disk 0, track 5, sector 0\n");
    DiskRead(disk_buf_B, 0, 5, 0, 1, &status);
    USLOSS_Console("start4(): DiskRead returned status = %d\n", status);
    USLOSS_Console("start4(): disk_buf_B contains:\n%s\n", disk_buf_B);
   
    USLOSS_Console("start4(): calling Terminate\n");
    Terminate(0);

    USLOSS_Console("start4(): should not see this message!\n");
    return 0;

} /* start4 */
示例#6
0
文件: sys.c 项目: TijmenW/FreeDOS
VOID put_boot(COUNT drive)
{
  COUNT i, z;
  WORD head, track, sector, ret;
  WORD count;
  ULONG temp;
  struct bootsectortype *bs;

  if (drive >= 2)
  {
    head = partition[active].peBeginHead;
    sector = partition[active].peBeginSector;
    track = partition[active].peBeginCylinder;
  }
  else
  {
    head = 0;
    sector = 1;
    track = 0;
  }

  /* Read current boot sector */
  if ((i = DiskRead(DrvMap[drive], head, track, sector, 1, (BYTE far *) oldboot)) != 0)
  {
    fprintf(stderr, "%s: disk read error (code = 0x%02x)\n", pgm, i & 0xff);
    exit(1);
  }

#ifdef DEBUG
  fprintf(log, "Old Boot Sector:\n");
  dump_sector(oldboot);
#endif

  bs = (struct bootsectortype *) & oldboot;
  if ((bs->bsFileSysType[4] == '6') && (bs->bsBootSignature == 0x29))
  {
    memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */
    printf("FAT type: FAT16\n");
#ifdef DEBUG
    fprintf(log, "FAT type: FAT16\n");
#endif
  }
  else
  {
    memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */
    printf("FAT type: FAT12\n");
#ifdef DEBUG
    fprintf(log, "FAT type: FAT12\n");
#endif
  }

  /* Copy disk parameter from old sector to new sector */
  memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE);

  bs = (struct bootsectortype *) & newboot;
  /* root directory sectors */
#ifdef STORE_BOOT_INFO
  bs->sysRootDirSecs = bs->bsRootDirEnts / 16;
#endif
#ifdef DEBUG
  fprintf(log, "root dir entries = %u\n", bs->bsRootDirEnts);
  fprintf(log, "root dir sectors = %u\n", bs->sysRootDirSecs);
#endif

  /* sector FAT starts on */
  temp = bs->bsHiddenSecs + bs->bsResSectors;
#ifdef STORE_BOOT_INFO
  bs->sysFatStart = temp;
#endif
#ifdef DEBUG
  fprintf(log, "FAT starts at sector %lu = (%lu + %u)\n", temp,
          bs->bsHiddenSecs, bs->bsResSectors);
#endif

  /* sector root directory starts on */
  temp = temp + bs->bsFATsecs * bs->bsFATs;
#ifdef STORE_BOOT_INFO
  bs->sysRootDirStart = temp;
#endif
#ifdef DEBUG
  fprintf(log, "Root directory starts at sector %lu = (PREVIOUS + %u * %u)\n",
          temp, bs->bsFATsecs, bs->bsFATs);
#endif

  /* sector data starts on */
  temp = temp + bs->sysRootDirSecs;
#ifdef STORE_BOOT_INFO
  bs->sysDataStart = temp;
#endif
#ifdef DEBUG
  fprintf(log, "DATA starts at sector %lu = (PREVIOUS + %u)\n", temp,
          bs->sysRootDirSecs);
#endif


#ifdef DEBUG
  fprintf(log, "\nNew Boot Sector:\n");
  dump_sector(newboot);
#endif

  if ((i = DiskWrite(DrvMap[drive], head, track, sector, 1, (BYTE far *) newboot)) != 0)
  {
    fprintf(stderr, "%s: disk write error (code = 0x%02x)\n", pgm, i & 0xff);
    exit(1);
  }
}
示例#7
0
void svc(SYSTEM_CALL_DATA *SystemCallData) {
	MEMORY_MAPPED_IO mmio; 
	short call_type;
	static short do_print = 10;
	INT32 Time;
	INT32 Status;
	short i;
	long* arg0=SystemCallData->Argument[0];
	long* arg1=SystemCallData->Argument[1];
	long* arg2=SystemCallData->Argument[2];
	long* arg3=SystemCallData->Argument[3];
	long* arg4=SystemCallData->Argument[4];
	long *arg5=SystemCallData->Argument[5];
	call_type = (short) SystemCallData->SystemCallNumber;
	if (do_print > 0) {
		printf("SVC handler: %s\n", call_names[call_type]);
		for (i = 0; i < SystemCallData->NumberOfArguments - 1; i++) {
			printf("Arg %d: Contents = (Decimal) %8ld,  (Hex) %8lX\n", i,
					(unsigned long) SystemCallData->Argument[i],
					(unsigned long) SystemCallData->Argument[i]);
		} 
		do_print--;
	}

	switch (call_type) {
		// Get time service call
		case SYSNUM_GET_TIME_OF_DAY:
			mmio.Mode = Z502ReturnValue;
			mmio.Field1 = mmio.Field2 = mmio.Field3 = 0;
			MEM_READ(Z502Clock, &mmio);//hardware call
			Time = mmio.Field1;
			(SystemCallData->Argument[0])=(long*)&Time;

			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;
				// get the Timer start and generate idle.
		case SYSNUM_SLEEP:

			startTimer(arg0);

			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);

			Dispatcher();//call dispatcher	

			break;

		// create process
		case SYSNUM_CREATE_PROCESS:
			OSCreateProcess(arg0,arg1,arg2,arg3,arg4);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;

		// get process id
		case SYSNUM_GET_PROCESS_ID:
			getProcessID(arg0,arg1,arg2);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;

		// suspend process
		case SYSNUM_SUSPEND_PROCESS:
			suspendProcess(arg0, arg1);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;
		
		// resume the process
		case SYSNUM_RESUME_PROCESS:
			resumeProcess(arg0, arg1);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;
		
		// change priority;
		case SYSNUM_CHANGE_PRIORITY:
			changePriority(arg0,arg1,arg2);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;

		// terminate system call
		case SYSNUM_TERMINATE_PROCESS:
			terminateSysProcess(arg0,arg1);
			break;

		case SYSNUM_SEND_MESSAGE:
			Send_message(arg0, arg1, arg2, arg3);

			break;

		case SYSNUM_RECEIVE_MESSAGE:
			ReceiveMessage(arg0, arg1, arg2, arg3, arg4, arg5);
			break;
		
		case SYSNUM_DISK_WRITE:
			DiskWrite(arg0, arg1, arg2);
			break;

		case SYSNUM_DISK_READ:
			DiskRead(arg0, arg1, arg2);
			break;

		case SYSNUM_DEFINE_SHARED_AREA:
			DefineSharedArea(arg0, arg1, arg2,arg3,arg4);
			break;

		default:
			printf( "ERROR!  call_type not recognized!\n" ); 
			printf( "Call_type is - %i\n", call_type);

	}
}                                               // End of svc