summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ndiscvt/ndiscvt.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2003-12-18 21:47:14 +0000
committerwpaul <wpaul@FreeBSD.org>2003-12-18 21:47:14 +0000
commit9916b5df7f088764ee235dc591abd537588a8e94 (patch)
tree20b7c8353565bcc6af001f6b6208908aed91684b /usr.sbin/ndiscvt/ndiscvt.c
parent27c5291e94075740c1bd19ba40d6c092c4ad490a (diff)
downloadFreeBSD-src-9916b5df7f088764ee235dc591abd537588a8e94.zip
FreeBSD-src-9916b5df7f088764ee235dc591abd537588a8e94.tar.gz
Make ndiscvt(8) emit the binary image array as inline assembly code rather
than a char array. Emitting the data as a big char array works fine in the typical case, where a .sys file may be ~50K in size. Unfortunately, some .sys files can be several hundred Kbytes in size, or even several megabytes in size. One extreme case is the Intel centrino wireless driver, which is 2.4MB. This causes us to emit an ndis_driver_data.h file that's on the order of 15MB in size, and gcc consumes enormous amounts of virtual memory while trying to compile it. On my laptop, with 128MB of RAM and 256MB of swap space, gcc consumed all available VM and crashed without being able to compile if_ndis.o. By emitting the array as assembler, we bypass the C compiler and consume much less memory. I was able to easily test compile if_ndis.ko with the centrino driver on my laptop after this change. This is merely a convenience, and should not have any operational effect on the NDISulator itself.
Diffstat (limited to 'usr.sbin/ndiscvt/ndiscvt.c')
-rw-r--r--usr.sbin/ndiscvt/ndiscvt.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/usr.sbin/ndiscvt/ndiscvt.c b/usr.sbin/ndiscvt/ndiscvt.c
index a29edc4..6e34fae 100644
--- a/usr.sbin/ndiscvt/ndiscvt.c
+++ b/usr.sbin/ndiscvt/ndiscvt.c
@@ -236,25 +236,33 @@ main(int argc, char *argv[])
fclose(fp);
}
- fprintf(outfp, "\n\nunsigned char drv_data[] = { \n");
+ fprintf(outfp, "\n\nextern unsigned char drv_data[];\n\n");
+
+ fprintf(outfp, "__asm__(\".data\");\n");
+ fprintf(outfp, "__asm__(\".type drv_data, @object\");\n");
+ fprintf(outfp, "__asm__(\".size drv_data, %d\");\n", fsize);
+ fprintf(outfp, "__asm__(\"drv_data:\");\n");
ptr = img;
cnt = 0;
while(cnt < fsize) {
- for (i = 0; i < 12; i++) {
+ fprintf (outfp, "__asm__(\".byte ");
+ for (i = 0; i < 10; i++) {
cnt++;
if (cnt == fsize) {
- fprintf(outfp, "0x%.2X\n", ptr[i]);
+ fprintf(outfp, "0x%.2X\");\n", ptr[i]);
goto done;
- } else
- fprintf(outfp, "0x%.2X, ", ptr[i]);
+ } else {
+ if (i == 9)
+ fprintf(outfp, "0x%.2X\");\n", ptr[i]);
+ else
+ fprintf(outfp, "0x%.2X, ", ptr[i]);
+ }
}
- fprintf(outfp, "\n");
- ptr += 12;
+ ptr += 10;
}
done:
- fprintf(outfp, "};\n");
if (fp != NULL)
fclose(fp);
OpenPOWER on IntegriCloud