Last fixes tonight
This commit is contained in:
@@ -39,20 +39,19 @@ polio.elf: polio-main.o polio.s fat12.o paracomm.o stdlib.o
|
||||
paracli.elf: LDFLAGS += -T doscom.ld
|
||||
paracli.elf: paracli.s paracomm.o
|
||||
|
||||
dos-programs = mushroom.elf hello.elf ftpget.elf
|
||||
$(dos-programs): LDFLAGS += -T doscom.ld
|
||||
dos-programs = mushroom.com hello.com ftpget.com
|
||||
$(dos-programs:.com=.elf): LDFLAGS += -T doscom.ld
|
||||
|
||||
mushroom.elf: mushroom.s
|
||||
hello.elf: hello.o stdlib.o crt0.s
|
||||
ftpget.elf: ftpget.o stdlib.o crt0.s
|
||||
|
||||
polos.img: fat12boot.bin polmon.com polio.com mushroom.com hello.com
|
||||
polos.img: fat12boot.bin polmon.com polio.com $(dos-programs)
|
||||
dd if=/dev/zero of=$@ bs=512 count=720
|
||||
mformat -i $@ -t 40 -h 2 -s 9
|
||||
mcopy -i $@ polio.com ::/
|
||||
mcopy -i $@ polmon.com ::/
|
||||
mcopy -i $@ mushroom.com ::/
|
||||
mcopy -i $@ hello.com ::/
|
||||
mcopy -i $@ $(dos-programs) ::/
|
||||
dd if=fat12boot.bin of=$@ conv=notrunc
|
||||
|
||||
.PHONY: clean
|
||||
|
@@ -19,15 +19,15 @@ int main(int argc, uint16_t argv[]) {
|
||||
|
||||
uint8_t ok = 0x42;
|
||||
|
||||
for (int i = 0; i < size; i += chunksize) {
|
||||
for (int i = 0; i < size; ) {
|
||||
runcomms(kUntilIdle);
|
||||
// delay?
|
||||
|
||||
uint8_t len = read(kLpt1, dest, chunksize);
|
||||
if (len == 0) {
|
||||
int len = read(kLpt1, dest + i, chunksize);
|
||||
if (len <= 0) {
|
||||
break;
|
||||
}
|
||||
write(kLpt1, &ok, 1);
|
||||
dest += len;
|
||||
i += len;
|
||||
}
|
||||
}
|
||||
|
40
src/stdlib.c
40
src/stdlib.c
@@ -46,13 +46,31 @@ void* memset(void* ptr, int val, size_t len) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int _int80h_2(uint8_t fun, uint16_t arg1, uint16_t arg2) {
|
||||
register uint16_t a1 asm("dx") = arg1;
|
||||
register uint16_t a2 asm("cx") = arg2;
|
||||
register uint8_t ah asm("ah") = fun;
|
||||
register uint16_t ret asm("ax");
|
||||
asm volatile("push %3 \n\t"
|
||||
"push %2 \n\t"
|
||||
"int $0x80 \n\t"
|
||||
"pop %%cx \n\t"
|
||||
"pop %%cx \n\t"
|
||||
: "=r"(ret)
|
||||
: "r"(ah), "r"(a1), "r"(a2)
|
||||
: "bx", "cc", "memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int runcomms(char until_idle) {
|
||||
register int ret asm("ax");
|
||||
register char ui asm("al") = until_idle;
|
||||
asm volatile("mov $0x07, %%ah \n\t"
|
||||
"int $0x80 \n\t"
|
||||
: "=r"(ret)
|
||||
: "r"(until_idle));
|
||||
: "r"(until_idle)
|
||||
: "bx", "cx", "dx", "cc", "memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -61,28 +79,12 @@ int read(int fd, void* buf, size_t size) {
|
||||
if (fd != kLpt1) {
|
||||
return -1;
|
||||
}
|
||||
register int ret asm("ax");
|
||||
asm volatile("push %2 \n\t"
|
||||
"push %1 \n\t"
|
||||
"mov $0x05, %%ah \n\t"
|
||||
"int $0x80 \n\t"
|
||||
: "=r"(ret)
|
||||
: "r"(buf), "r"(size));
|
||||
|
||||
return ret;
|
||||
return _int80h_2(0x05, (uint16_t)buf, size);
|
||||
}
|
||||
|
||||
int write(int fd, void* buf, size_t size) {
|
||||
if (fd != kLpt1) {
|
||||
return -1;
|
||||
}
|
||||
register int ret asm("ax");
|
||||
asm volatile("push %2 \n\t"
|
||||
"push %1 \n\t"
|
||||
"mov $0x06, %%ah \n\t"
|
||||
"int $0x80 \n\t"
|
||||
: "=r"(ret)
|
||||
: "r"(buf), "r"(size));
|
||||
|
||||
return ret;
|
||||
return _int80h_2(0x06, (uint16_t)buf, size);
|
||||
}
|
||||
|
Reference in New Issue
Block a user