aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules
diff options
context:
space:
mode:
authorShao Miller <shao.miller@yrdsb.edu.on.ca>2010-06-28 02:14:08 -0400
committerShao Miller <shao.miller@yrdsb.edu.on.ca>2010-07-10 01:03:05 -0400
commit86bf50325b73618cd67a67d5b9a1781877493c07 (patch)
tree07ae8e16f2f5826b2354be9b04d37294626f7b8e /com32/modules
parent1cf649982aed3bd020909939c491ed19a412e5ea (diff)
downloadsyslinux-86bf50325b73618cd67a67d5b9a1781877493c07.tar.gz
syslinux-86bf50325b73618cd67a67d5b9a1781877493c07.tar.xz
syslinux-86bf50325b73618cd67a67d5b9a1781877493c07.zip
chain.c32, libcom32: Move write_sector() as disk_write_sector()
Moving portions of chain.c32 into libcom32. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Diffstat (limited to 'com32/modules')
-rw-r--r--com32/modules/chain.c59
1 files changed, 1 insertions, 58 deletions
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index 0ff1ea1f..de827a20 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -147,69 +147,12 @@ static inline void error(const char *msg)
static struct disk_info diskinfo;
-static int write_sector(unsigned int lba, const void *data)
-{
- com32sys_t inreg;
- struct disk_ebios_dapa *dapa = __com32.cs_bounce;
- void *buf = (char *)__com32.cs_bounce + SECTOR;
-
- memcpy(buf, data, SECTOR);
- memset(&inreg, 0, sizeof inreg);
-
- if (diskinfo.ebios) {
- dapa->len = sizeof(*dapa);
- dapa->count = 1; /* 1 sector */
- dapa->off = OFFS(buf);
- dapa->seg = SEG(buf);
- dapa->lba = lba;
-
- inreg.esi.w[0] = OFFS(dapa);
- inreg.ds = SEG(dapa);
- inreg.edx.b[0] = diskinfo.disk;
- inreg.eax.w[0] = 0x4300; /* Extended write */
- } else {
- unsigned int c, h, s, t;
-
- if (!diskinfo.cbios) {
- /* We failed to get the geometry */
-
- if (lba)
- return -1; /* Can only write MBR */
-
- s = 1;
- h = 0;
- c = 0;
- } else {
- s = (lba % diskinfo.sect) + 1;
- t = lba / diskinfo.sect; /* Track = head*cyl */
- h = t % diskinfo.head;
- c = t / diskinfo.head;
- }
-
- if (s > 63 || h > 256 || c > 1023)
- return -1;
-
- inreg.eax.w[0] = 0x0301; /* Write one sector */
- inreg.ecx.b[1] = c & 0xff;
- inreg.ecx.b[0] = s + (c >> 6);
- inreg.edx.b[1] = h;
- inreg.edx.b[0] = diskinfo.disk;
- inreg.ebx.w[0] = OFFS(buf);
- inreg.es = SEG(buf);
- }
-
- if (disk_int13_retry(&inreg, NULL))
- return -1;
-
- return 0; /* ok */
-}
-
static int write_verify_sector(unsigned int lba, const void *buf)
{
char *rb;
int rv;
- rv = write_sector(lba, buf);
+ rv = disk_write_sector(&diskinfo, lba, buf);
if (rv)
return rv; /* Write failure */
rb = disk_read_sectors(&diskinfo, lba, 1);