VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/floppyt.c@ 62509

Last change on this file since 62509 was 62509, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: floppyt.c 62509 2016-07-22 19:12:22Z vboxsync $ */
2/** @file
3 * Floppy drive tables.
4 */
5
6/*
7 * Copyright (C) 2011-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include <stdint.h>
19#include <string.h>
20#include "biosint.h"
21#include "inlines.h"
22
23/**
24 * Extended DPT (Disk Parameter Table) structure.
25 */
26typedef struct
27{
28 uint8_t spec1; /* First SPECIFY byte. */
29 uint8_t spec2; /* Second SPECIFY byte. */
30 uint8_t mot_wait; /* Motor wait time after operation. */
31 uint8_t ss_code; /* Sector size code. */
32 uint8_t eot; /* End of Track (ID of last sector). */
33 uint8_t gap; /* Gap length. */
34 uint8_t dtl; /* Data length. */
35 uint8_t fmt_gap; /* Gap length for format. */
36 uint8_t fmt_fill; /* Format fill byte. */
37 uint8_t hd_settle; /* Head settle time (msec). */
38 uint8_t mot_start; /* Motor start time (1/8 sec units). */
39 uint8_t max_trk; /* Maximum track number. */
40 uint8_t rate; /* Data transfer rate code. */
41} dpt_ext;
42
43ct_assert(sizeof(dpt_ext) == 13);
44
45/* Motor spin-up wait time in BIOS ticks (~2 seconds). */
46#define MOTOR_WAIT 0x25
47
48/* Data rates as stored in the DPT */
49#define RATE_250K 0x80
50#define RATE_300K 0x40
51#define RATE_500K 0x00
52#define RATE_1M 0xC0
53
54/* In the 13-entry DPT, 7 entries are constant. Use a macro to set those. */
55#define MAKE_DPT_ENTRY(sp1, eot, gap, fgp, mxt, dtr) \
56 { sp1, 2, MOTOR_WAIT, 2, eot, gap, 0xFF, fgp, 0xF6, 15, 8, mxt, dtr }
57
58dpt_ext fd_parm[] = {
59 MAKE_DPT_ENTRY(0xDF, 9, 0x2A, 0x50, 39, RATE_250K), /* 360K disk/360K drive */
60 MAKE_DPT_ENTRY(0xDF, 9, 0x2A, 0x50, 39, RATE_300K), /* 360K disk/1.2M drive */
61 MAKE_DPT_ENTRY(0xDF, 15, 0x1B, 0x54, 79, RATE_500K), /* 1.2M disk */
62 MAKE_DPT_ENTRY(0xDF, 9, 0x2A, 0x50, 79, RATE_250K), /* 720K disk */
63 MAKE_DPT_ENTRY(0xAF, 18, 0x1B, 0x6C, 79, RATE_500K), /* 1.44M disk */
64 MAKE_DPT_ENTRY(0xAF, 36, 0x1B, 0x54, 79, RATE_1M), /* 2.88M disk */
65 MAKE_DPT_ENTRY(0xAF, 255, 0x1B, 0x54, 255, RATE_500K) /* Fake mega-disk */
66};
67
68typedef struct {
69 uint8_t type; /* Drive type. */
70 uint8_t dpt_entry; /* Index of entry in fd_parm. */
71} fd_map_entry;
72
73/* Drive types as stored in the CMOS. Must match DevPCBios! */
74#define FDRV_360K 1
75#define FDRV_1_2M 2
76#define FDRV_720K 3
77#define FDRV_1_44M 4
78#define FDRV_2_88M 5
79#define FDRV_15M 14
80#define FDRV_63M 15
81
82/* A table mapping (CMOS) drive types to DPT entries. */
83fd_map_entry fd_map[] = {
84 { FDRV_360K, 0 },
85 { FDRV_1_2M, 2 },
86 { FDRV_720K, 3 },
87 { FDRV_1_44M, 4 },
88 { FDRV_2_88M, 5 },
89 { FDRV_15M, 6 },
90 { FDRV_63M, 6 }
91};
92
93/* Find a DPT corresponding to the given drive type. */
94dpt_ext *get_floppy_dpt(uint8_t drv_typ)
95{
96 int i;
97
98 for (i = 0; i < sizeof(fd_map) / sizeof(fd_map[0]); ++i)
99 if (fd_map[i].type == drv_typ)
100 return &fd_parm[fd_map[i].dpt_entry];
101
102 /* As a fallback, return the 1.44M DPT. */
103 return &fd_parm[5];
104}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette