[syslinux] gpllib write_sectors() patch
Don Hiatt
donhiatt at gmail.com
Tue Apr 27 10:15:56 PDT 2010
Here is a partial patch that I'm using to illustrate a few questions
that I have.
Looking at the gpllib write_sectors (com32/gpllib/disk/write.c) it
looks like the allocated
size is wrong; size is in sectors so we should adjust the alloc/memcpy
by size*SECTOR.
Also, comparing core/diskio.c it looks like the registers aren't even
setup right.
In the patch below I put an #if 0 around the old code to demonstrate
how it differs
from diskio.c
I also added a call to get_drive_parameters() so that it would be like
the gpllib/read.c
However, it would probably be best to not have to call
get_drive_parameters every time
so they should be supplied in the driveinfo struct (for both read and write).
/**
* write_sectors - write several sectors from disk
@@ -37,9 +55,14 @@ int write_sectors(const struct driveinfo
*drive_info, const unsigned int lba,
{
com32sys_t inreg, outreg;
struct ebios_dapa *dapa = __com32.cs_bounce;
- void *buf = (char *)__com32.cs_bounce + size;
+ void *buf = (char *)__com32.cs_bounce + size*SECTOR;
- memcpy(buf, data, size);
+ if (get_drive_parameters(drive_info) == -1) {
+ printf("ERR: Can't get drive params!\n");
+ return -1;
+ }
+
+ memcpy(buf, data, size*SECTOR);
memset(&inreg, 0, sizeof inreg);
if (drive_info->ebios) {
@@ -48,11 +71,17 @@ int write_sectors(const struct driveinfo
*drive_info, const unsigned int lba,
dapa->off = OFFS(buf);
dapa->seg = SEG(buf);
dapa->lba = lba;
-
+#if 0
inreg.esi.w[0] = OFFS(dapa);
inreg.ds = SEG(dapa);
inreg.edx.b[0] = drive_info->disk;
inreg.eax.w[0] = 0x4300; /* Extended write */
+#endif
+ inreg.eax.b[1] = 0x43;
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.ds = SEG(dapa);
+ inreg.esi.w[0] = OFFS(dapa);
+
More information about the Syslinux
mailing list