aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2014-01-17 17:03:00 -0800
committerH. Peter Anvin <hpa@zytor.com>2014-01-17 17:04:40 -0800
commitec8d8333983857d3c78311c52635651bf4363e28 (patch)
tree892825a3ffc7bdf8c6dc0da68bd379d5672efe2c
parent607617d7ff7ead7f8ff42c5f7598d7a240842811 (diff)
downloadhdt-ec8d8333983857d3c78311c52635651bf4363e28.tar.gz
hdt-ec8d8333983857d3c78311c52635651bf4363e28.tar.xz
hdt-ec8d8333983857d3c78311c52635651bf4363e28.zip
dos: Add sparse address space annotations
Add sparse address space annotation to the actual DOS installer code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--dos/syslinux.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/dos/syslinux.c b/dos/syslinux.c
index 63a3a854..8e856d4f 100644
--- a/dos/syslinux.c
+++ b/dos/syslinux.c
@@ -121,29 +121,32 @@ int rename(const char *oldname, const char *newname)
return 0;
}
-ssize_t write_file_seg(int fd, unsigned char *buf, const unsigned int len)
+ssize_t write_file_sl(int fd, const unsigned char _slimg *buf,
+ const unsigned int len)
{
- uint16_t seg = ((size_t)buf >> 4) + ds();
- uint32_t offset = 0;
+ uint32_t filepos = 0;
uint16_t rv;
uint8_t err;
- while (offset < len) {
- uint32_t chunk = len - offset;
- if (chunk > 32768)
- chunk = 32768;
+ while (filepos < len) {
+ uint16_t seg = ((size_t)buf >> 4) + ds();
+ uint16_t offset = (size_t)buf & 15;
+ uint32_t chunk = len - filepos;
+ if (chunk > 32768 - offset)
+ chunk = 32768 - offset;
asm volatile ("pushw %%ds ; "
"movw %6,%%ds ; "
"int $0x21 ; "
"popw %%ds ; " "setc %0":"=bcdm" (err), "=a"(rv)
- :"a"(0x4000), "b"(fd), "c"(chunk), "d" (offset & 15),
- "SD" ((uint16_t)(seg + (offset >> 4))));
+ :"a"(0x4000), "b"(fd), "c"(chunk), "d" (offset),
+ "SD" (seg));
if (err || rv == 0)
die("file write error");
- offset += rv;
+ filepos += rv;
+ buf += rv;
}
- return offset;
+ return filepos;
}
ssize_t write_file(int fd, const void *buf, size_t count)
@@ -685,14 +688,14 @@ int main(int argc, char *argv[])
set_attributes(ldlinux_name, 0);
fd = creat(ldlinux_name, 0); /* SYSTEM HIDDEN READONLY */
- write_file_seg(fd, syslinux_ldlinux, syslinux_ldlinux_len);
+ write_file_sl(fd, syslinux_ldlinux, syslinux_ldlinux_len);
write_file(fd, syslinux_adv, 2 * ADV_SIZE);
close(fd);
set_attributes(ldlinux_name, 0x07); /* SYSTEM HIDDEN READONLY */
set_attributes(ldlinuxc32_name, 0);
fd = creat(ldlinuxc32_name, 0); /* SYSTEM HIDDEN READONLY */
- write_file_seg(fd, syslinux_ldlinuxc32, syslinux_ldlinuxc32_len);
+ write_file_sl(fd, syslinux_ldlinuxc32, syslinux_ldlinuxc32_len);
close(fd);
set_attributes(ldlinuxc32_name, 0x07); /* SYSTEM HIDDEN READONLY */