Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f28b9cfb65 | ||
|
|
0677a383e0 | ||
|
|
15b46c5763 | ||
|
|
389eefd0cd | ||
|
|
78e54426c0 | ||
|
|
7296f1f21c | ||
|
|
489bd2f396 | ||
|
|
224ef7f483 | ||
|
|
251926f631 | ||
|
|
04cb1cde5c | ||
|
|
db3e054fe5 | ||
|
|
d07f79de35 | ||
|
|
0ea6e5c221 | ||
|
|
b0b0b8f65c | ||
|
|
3fa2779208 | ||
|
|
584e378241 | ||
|
|
1bb420448c | ||
|
|
ec5863a7f5 | ||
|
|
9f7141a1ce | ||
|
|
4175b778c2 | ||
|
|
c9c411286a | ||
|
|
0fc13add31 | ||
|
|
d7dfc9572e | ||
|
|
a7290a970c | ||
|
|
2310c30d1c | ||
|
|
444d5550a7 | ||
|
|
4eab5bc8ca | ||
|
|
37a0aab4ff | ||
|
|
b3db99a38d | ||
|
|
d5d68b2e31 | ||
|
|
487347a0cd | ||
|
|
e5f14e5a32 | ||
|
|
0ff5c456cb | ||
|
|
965a0f7a75 | ||
|
|
a0d337912e | ||
|
|
0c30dc6bc5 | ||
|
|
8de49af0d2 | ||
|
|
419243e7f1 | ||
|
|
4be11f523c | ||
|
|
1175f0cf29 | ||
|
|
0b1222f233 | ||
|
|
cf716a0ce6 | ||
|
|
d944794680 | ||
|
|
976f12c501 | ||
|
|
04878ef745 | ||
|
|
46073f1239 | ||
|
|
ce68f587e2 | ||
|
|
3f274a6950 | ||
|
|
fc9750a68d | ||
|
|
0b3c88e035 | ||
|
|
1e810bebe9 | ||
|
|
f128a6db21 | ||
|
|
e6e30618c2 | ||
|
|
34bfc04e4c | ||
|
|
44251ebb9a | ||
|
|
0e07516f62 | ||
|
|
18bcdfb1cc | ||
|
|
7a3a159af5 | ||
|
|
ad66465b3c | ||
|
|
b0c563824b | ||
|
|
1f7d550246 | ||
|
|
70f47e675e | ||
|
|
993f8ba9bc | ||
|
|
5e1aa70301 | ||
|
|
193d545903 | ||
|
|
bba00b0c13 | ||
|
|
2b9f7f042c | ||
|
|
5552a1b202 | ||
|
|
f42b2932f8 | ||
|
|
b570c2efd8 | ||
|
|
96f4f96540 | ||
|
|
14ae602ef0 | ||
|
|
ce64398f87 | ||
|
|
bb2cf3c8d7 | ||
|
|
cd5a21359c | ||
|
|
de50a19ae3 | ||
|
|
dd2788594b | ||
|
|
cc2e767b5a | ||
|
|
c939bc57ff | ||
|
|
ea6eb7f7ed | ||
|
|
0095e18d4c | ||
|
|
773028d34e | ||
|
|
94876f4bb6 | ||
|
|
f1d92fa886 | ||
|
|
92cf240020 | ||
|
|
80c41b90d2 | ||
|
|
3f4972db9a | ||
|
|
0582a84e66 | ||
|
|
47c4aaa9e2 | ||
|
|
165074c188 | ||
|
|
8a852280eb | ||
|
|
cb9ef4dee2 | ||
|
|
63c112ed38 | ||
|
|
0fbf2f6bda | ||
|
|
3c77fe73a5 | ||
|
|
b4155c4ab5 | ||
|
|
8aa2591c06 | ||
|
|
06ad481904 | ||
|
|
4d0029611f | ||
|
|
d6b47871de | ||
|
|
1d8c85d112 | ||
|
|
365b8db5cf | ||
|
|
887d296b88 | ||
|
|
1f5c0239b4 | ||
|
|
7ba33f7826 | ||
|
|
b25a4b6c8a | ||
|
|
8868956268 | ||
|
|
d09290161e | ||
|
|
54ec3673cc | ||
|
|
acfd7cc609 | ||
|
|
1d8d8ef2c8 | ||
|
|
51172783e2 | ||
|
|
b7e93a6a55 | ||
|
|
546cc62394 | ||
|
|
76c915d5bd | ||
|
|
6e564323e0 | ||
|
|
ee1d315ac0 | ||
|
|
07b5be3341 | ||
|
|
c2965b0fe7 | ||
|
|
c26a38b313 | ||
|
|
f186ada2d3 | ||
|
|
9580f9d5cd | ||
|
|
15ce2fb851 | ||
|
|
6254998327 | ||
|
|
4125216a2f | ||
|
|
a310d00d37 | ||
|
|
cb9700ef6f | ||
|
|
4fe1e08a60 | ||
|
|
0b922595fe | ||
|
|
4f881ae352 | ||
|
|
ded4d3a703 | ||
|
|
198ae0a131 | ||
|
|
5e1ef98469 | ||
|
|
58f60df66c | ||
|
|
99e64f5806 | ||
|
|
f4605970f4 | ||
|
|
a2f753ba64 | ||
|
|
f8448735b0 | ||
|
|
254bdc2a8e | ||
|
|
eb3ca2a36f | ||
|
|
743ebc2f4b | ||
|
|
558c1a45fe | ||
|
|
68973f1c49 | ||
|
|
edfbd4e4fa | ||
|
|
4c5f00f879 | ||
|
|
5e51aaccaa | ||
|
|
a5cd8d1772 | ||
|
|
92a9978b44 | ||
|
|
8afafb6532 | ||
|
|
e47869995f | ||
|
|
1f80b2dcd5 | ||
|
|
b8469eddaa | ||
|
|
005fce0258 | ||
|
|
3c06277bbb | ||
|
|
822b3b53f4 | ||
|
|
c345336435 | ||
|
|
f51d61371f | ||
|
|
1958974d0a | ||
|
|
c5a88ed553 | ||
|
|
3961c1ca02 | ||
|
|
9119b0c8af | ||
|
|
f4bf4e69f7 | ||
|
|
c44a193d0d | ||
|
|
41307f2874 | ||
|
|
a525fb7782 | ||
|
|
a13fc96cb3 | ||
|
|
4188d51753 | ||
|
|
7c47ebd65c | ||
|
|
6e764282dd | ||
|
|
bb06fc17cc | ||
|
|
9b964dec36 | ||
|
|
4b8e021161 | ||
|
|
e960fac8d0 | ||
|
|
ad027e41e5 | ||
|
|
a1eb4ffdf7 | ||
|
|
ead44dba89 | ||
|
|
3d6b8a67f2 | ||
|
|
f721067d35 | ||
|
|
a63ef9207d | ||
|
|
f79608b376 | ||
|
|
b4a87daeb9 | ||
|
|
7aee624881 | ||
|
|
7741546a40 | ||
|
|
b363d19a16 | ||
|
|
cc4363acca | ||
|
|
38a1d0fe3f | ||
|
|
b149a99302 | ||
|
|
f44205b9ea | ||
|
|
dc387547a3 | ||
|
|
3dd7ce1c26 | ||
|
|
7266aceb39 | ||
|
|
820b11dc0a | ||
|
|
210bc9e9ba | ||
|
|
bbd274a1d6 | ||
|
|
e3b9e3d04b | ||
|
|
b0c818d7b5 | ||
|
|
f7d2168c8e | ||
|
|
edea441ad5 | ||
|
|
272e6ddc30 | ||
|
|
323cdf8c4c | ||
|
|
abc13af070 | ||
|
|
a436dc4014 | ||
|
|
a323a85d9b | ||
|
|
f3335b83d4 | ||
|
|
5538a38b9c | ||
|
|
03ff8cd3e2 | ||
|
|
3da6f1c7bd | ||
|
|
87b494bbab | ||
|
|
5bd32315d0 | ||
|
|
1c67623e37 | ||
|
|
16aa435567 | ||
|
|
90c01ef1e4 | ||
|
|
3c68ff99ea | ||
|
|
1266d7902b | ||
|
|
3ed468e0c5 | ||
|
|
4397a2a4ca | ||
|
|
f3d09b5c79 | ||
|
|
ec24672db7 | ||
|
|
f95c919741 | ||
|
|
e103495563 | ||
|
|
518cd2f192 | ||
|
|
afe59d4636 | ||
|
|
b9d791f4d1 | ||
|
|
4f3bab1a55 | ||
|
|
43834f5d25 | ||
|
|
784d3f336e | ||
|
|
6a3f5d6db7 | ||
|
|
4dd746a725 | ||
|
|
78d426d196 | ||
|
|
9937bf13c9 | ||
|
|
e950dc04ba | ||
|
|
b4d3d686cc | ||
|
|
a3219b24a8 | ||
|
|
5de8305feb | ||
|
|
991f907d5b | ||
|
|
aaa26f3bd3 | ||
|
|
b5577553e5 | ||
|
|
dd44a7c314 | ||
|
|
7b1a5a7997 | ||
|
|
3206e470d0 | ||
|
|
6de4db5da0 | ||
|
|
bea828b9ed | ||
|
|
54840039f6 | ||
|
|
67ee41ad6d | ||
|
|
cff419148c | ||
|
|
06b5132fdc | ||
|
|
dbbd81c140 | ||
|
|
5026a35fef | ||
|
|
7f903f03af | ||
|
|
14eafc5b8d | ||
|
|
8904cd55f1 | ||
|
|
349868b8fd | ||
|
|
7bc4093e1a | ||
|
|
b08e255ef1 | ||
|
|
78a57a6f76 | ||
|
|
24e948f030 | ||
|
|
076154a1c6 | ||
|
|
f16668dd60 | ||
|
|
79867d34ee | ||
|
|
c9e5b12473 | ||
|
|
ce2aa66d39 | ||
|
|
8ae1cac050 | ||
|
|
46da51703a | ||
|
|
816a32aaee | ||
|
|
ef70f87997 | ||
|
|
d900ae05d7 | ||
|
|
4e6b62c946 | ||
|
|
8e960eb67c | ||
|
|
5a99c586cf | ||
|
|
750c19466a | ||
|
|
e9c10ca158 | ||
|
|
56066a6085 | ||
|
|
881f1f59ef | ||
|
|
ff2b308506 | ||
|
|
4b276b8df9 | ||
|
|
dbe84c5aad | ||
|
|
0171098212 | ||
|
|
4502c04360 | ||
|
|
6711ce18a7 | ||
|
|
e65afc4b10 | ||
|
|
d2b0081740 | ||
|
|
b111bdfb00 | ||
|
|
52c596bafb | ||
|
|
d10a7e7739 | ||
|
|
a128973ecb | ||
|
|
1284773363 | ||
|
|
027c72e0d0 | ||
|
|
f1d17ae2be | ||
|
|
ce9690ca39 | ||
|
|
3f814f08e5 | ||
|
|
773d9631ef | ||
|
|
76d05a4da0 | ||
|
|
cf53998901 | ||
|
|
6941793416 | ||
|
|
d230b53df2 | ||
|
|
b4a95a8974 | ||
|
|
7be5fa82e3 | ||
|
|
d7de30e5e4 | ||
|
|
08f6d22410 | ||
|
|
aa86afe890 | ||
|
|
cced04ef3b | ||
|
|
8fd81349b3 | ||
|
|
48b2f70ee4 | ||
|
|
ba1016f378 | ||
|
|
3e220aa73e | ||
|
|
fb72336fe6 | ||
|
|
765efac771 | ||
|
|
314779eb36 | ||
|
|
85e5e25c52 | ||
|
|
21cfab4fb8 | ||
|
|
53a7dd26cd | ||
|
|
8674bc05a0 | ||
|
|
57bbf0ec98 | ||
|
|
1941c933f8 | ||
|
|
1206999288 | ||
|
|
ce0a0ccf5c | ||
|
|
b0d2c9a4d5 | ||
|
|
29480dd715 | ||
|
|
045a22764a | ||
|
|
3a799e99ca | ||
|
|
4d7c650164 | ||
|
|
708e6e0613 | ||
|
|
74b7bc0954 | ||
|
|
7166bc7b2d | ||
|
|
e78bcb6175 | ||
|
|
02a0215873 | ||
|
|
8e8a348fd4 | ||
|
|
246ddf5ee4 | ||
|
|
a2686a55c4 | ||
|
|
b48f37e69a | ||
|
|
14a739ba6a | ||
|
|
d3d8f20626 | ||
|
|
fc49421c7e | ||
|
|
5dd5107976 | ||
|
|
0ebbbb95fa | ||
|
|
7d36a1b7b0 | ||
|
|
3f85626fa9 | ||
|
|
d9b3d09910 | ||
|
|
b59e0cc56e | ||
|
|
849e4b12d6 | ||
|
|
dc60c24146 | ||
|
|
446b6d5fdd | ||
|
|
fca2dcabb8 | ||
|
|
ab96932ab3 | ||
|
|
0a8a17e669 | ||
|
|
85f82f09e9 | ||
|
|
cc93556725 | ||
|
|
c661945e82 | ||
|
|
54fbd11221 | ||
|
|
464bf35cc0 | ||
|
|
8a80e7ace1 | ||
|
|
1b3edd9e11 | ||
|
|
2ca2607b1b | ||
|
|
125c6d66a8 | ||
|
|
9e5fd8ec59 | ||
|
|
c0ec00f47f | ||
|
|
9a35830d1f | ||
|
|
663904a7bc | ||
|
|
830e19eb54 | ||
|
|
0de5f7af6d | ||
|
|
d9751edafa | ||
|
|
dd34500188 | ||
|
|
180d99fc22 | ||
|
|
9a52ba0cfa | ||
|
|
46f43d8ea7 | ||
|
|
43aa69d7b3 | ||
|
|
ed196a3ed2 | ||
|
|
29e6f9835e | ||
|
|
aa95744915 | ||
|
|
5e6b82104d | ||
|
|
32bc76f902 | ||
|
|
467c4f77c3 | ||
|
|
0a6c66a830 | ||
|
|
621101c36a | ||
|
|
1bc2adea9a | ||
|
|
664f4cf365 | ||
|
|
df033de24f | ||
|
|
7a4c129af7 | ||
|
|
3fe6bede74 | ||
|
|
d4c8273569 | ||
|
|
bcc70d6b99 | ||
|
|
612f4e7a99 | ||
|
|
cbf9003d66 | ||
|
|
85f09b5fc0 | ||
|
|
22979c511e | ||
|
|
d9c38d14d6 | ||
|
|
5600955bdd | ||
|
|
7982e79d3c | ||
|
|
04f3206581 | ||
|
|
58dd6e04c5 | ||
|
|
744b98d273 | ||
|
|
c99b16c974 | ||
|
|
3a505dfc35 | ||
|
|
6b9cc25556 | ||
|
|
832668105e | ||
|
|
64e5ca0582 | ||
|
|
81d92c6d34 | ||
|
|
54c024e0af | ||
|
|
d4e152e766 | ||
|
|
07e8f18f33 | ||
|
|
831e4cfc27 | ||
|
|
6554b79ff9 | ||
|
|
667819becc | ||
|
|
c0835339d0 | ||
|
|
658c6dba59 | ||
|
|
16f1e35775 | ||
|
|
e6f276ece3 | ||
|
|
f945d6d201 | ||
|
|
941b4c2adb | ||
|
|
8a4ccebec9 | ||
|
|
fd67452807 | ||
|
|
e226a8d8d9 | ||
|
|
8c7deba349 | ||
|
|
aef6d0df5c | ||
|
|
992bbf309c | ||
|
|
8e38669d54 | ||
|
|
a1e11a6beb | ||
|
|
1641b5d39b | ||
|
|
ee2df1d6d6 | ||
|
|
8956a36be5 | ||
|
|
b40b4f2dbf | ||
|
|
0b5c39d167 | ||
|
|
2e812235f4 | ||
|
|
ac663cf509 | ||
|
|
13d09e6719 | ||
|
|
3029eb0e84 | ||
|
|
5c695db474 | ||
|
|
98abd48a26 | ||
|
|
3f80f9e1a6 | ||
|
|
cdd619d11f | ||
|
|
96ea558e98 | ||
|
|
e817a347fb | ||
|
|
a2588547f9 | ||
|
|
f0b942ef42 | ||
|
|
160b950af8 | ||
|
|
19a0452205 | ||
|
|
521549d900 | ||
|
|
9dccbc0af2 | ||
|
|
91802c6e85 | ||
|
|
afe1323c76 | ||
|
|
9b01a9fd9c | ||
|
|
60c3b69c31 |
+13
-20
@@ -1,5 +1,5 @@
|
|||||||
Running Etherboot within qemu
|
Running gPXE within qemu
|
||||||
=============================
|
========================
|
||||||
|
|
||||||
Michael Brown <mbrown@fensystems.co.uk>
|
Michael Brown <mbrown@fensystems.co.uk>
|
||||||
|
|
||||||
@@ -9,13 +9,10 @@ To get qemu running is fairly simple:
|
|||||||
make
|
make
|
||||||
|
|
||||||
2. Get the qemu source code:
|
2. Get the qemu source code:
|
||||||
cvs -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/qemu \
|
svn co svn://svn.savannah.nongnu.org/qemu/trunk qemu
|
||||||
login
|
|
||||||
cvs -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/qemu \
|
|
||||||
co qemu
|
|
||||||
|
|
||||||
2a. Patch the qemu code. There is currently a bug that causes qemu to
|
2a. Patch the qemu code. There is currently a bug that causes qemu to
|
||||||
execute Etherboot incredibly slowly. The bug seems to be related
|
execute gPXE incredibly slowly. The bug seems to be related
|
||||||
to the relative prioritisation of CPU and I/O operations within
|
to the relative prioritisation of CPU and I/O operations within
|
||||||
qemu. This patch (which I found via Google) isn't a proper fix,
|
qemu. This patch (which I found via Google) isn't a proper fix,
|
||||||
but it does work around the problem:
|
but it does work around the problem:
|
||||||
@@ -23,13 +20,9 @@ To get qemu running is fairly simple:
|
|||||||
|
|
||||||
3. Configure qemu with
|
3. Configure qemu with
|
||||||
pushd qemu
|
pushd qemu
|
||||||
./configure --enable-system
|
./configure --target-list=i386-softmmu,x86_64-softmmu
|
||||||
popd
|
popd
|
||||||
|
|
||||||
Note that qemu will not compile with gcc4; if your system's
|
|
||||||
default compiler is gcc4 then specify the path to gcc3 using
|
|
||||||
e.g. --cc=gcc-3.3.6
|
|
||||||
|
|
||||||
4. Build qemu:
|
4. Build qemu:
|
||||||
make -C qemu
|
make -C qemu
|
||||||
|
|
||||||
@@ -44,7 +37,7 @@ To get qemu running is fairly simple:
|
|||||||
range dynamic-bootp 10.254.254.1 10.254.254.1;
|
range dynamic-bootp 10.254.254.1 10.254.254.1;
|
||||||
}
|
}
|
||||||
You will also need to add in any of your usual declarations for
|
You will also need to add in any of your usual declarations for
|
||||||
Etherboot, e.g. 'filename "vmlinuz.ltsp";'. Note that this setup
|
gPXE, e.g. 'filename "vmlinuz.ltsp";'. Note that this setup
|
||||||
assumes that your DHCP server, TFTP server etc. all live on the
|
assumes that your DHCP server, TFTP server etc. all live on the
|
||||||
machine you are using for running qemu. If not, then you're on
|
machine you are using for running qemu. If not, then you're on
|
||||||
your own.
|
your own.
|
||||||
@@ -52,18 +45,18 @@ To get qemu running is fairly simple:
|
|||||||
7. As root, restart dhcpd
|
7. As root, restart dhcpd
|
||||||
/etc/init.d/dhcpd restart
|
/etc/init.d/dhcpd restart
|
||||||
|
|
||||||
8. Build Etherboot floppy disk images and pad to 1.44MB
|
8. Build gPXE floppy disk images and pad to 1.44MB
|
||||||
pushd ../../src
|
pushd ../../src
|
||||||
make bin/rtl8139.pdsk
|
make bin/rtl8139.dsk
|
||||||
popd
|
popd
|
||||||
|
|
||||||
9. Start qemu
|
9. Start qemu
|
||||||
./qemu/i386-softmmu/qemu -L qemu/pc-bios \
|
./qemu/i386-softmmu/qemu -L qemu/pc-bios \
|
||||||
-net nic,model=rtl8139 -net tap,ifname=tap0 \
|
-net nic,model=rtl8139 -net tap,ifname=tap0 \
|
||||||
-boot a -fda ../../src/bin/rtl8139.pdsk
|
-boot a -fda ../../src/bin/rtl8139.dsk
|
||||||
|
|
||||||
You should see qemu start up, load up Etherboot and attempt to boot
|
You should see qemu start up, load up gPXE and attempt to boot from
|
||||||
from the network.
|
the network.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -71,8 +64,8 @@ Serial console
|
|||||||
==============
|
==============
|
||||||
|
|
||||||
You can use the program "serial-console" to obtain a virtual serial
|
You can use the program "serial-console" to obtain a virtual serial
|
||||||
console for Etherboot running within qemu. Run "./serial-console" on
|
console for gPXE running within qemu. Run "./serial-console" on a
|
||||||
a spare tty (e.g. a separate xterm window) before starting qemu, and
|
spare tty (e.g. a separate xterm window) before starting qemu, and
|
||||||
ensure that you have enabled CONSOLE_SERIAL in config.h.
|
ensure that you have enabled CONSOLE_SERIAL in config.h.
|
||||||
|
|
||||||
When serial-console starts, it will print out the message "Slave pty
|
When serial-console starts, it will print out the message "Slave pty
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
Index: memory/memory.cc
|
||||||
|
===================================================================
|
||||||
|
RCS file: /cvsroot/bochs/bochs/memory/memory.cc,v
|
||||||
|
retrieving revision 1.71
|
||||||
|
diff -u -r1.71 memory.cc
|
||||||
|
--- memory/memory.cc 18 Oct 2008 18:10:14 -0000 1.71
|
||||||
|
+++ memory/memory.cc 21 Oct 2008 19:47:07 -0000
|
||||||
|
@@ -172,7 +172,11 @@
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x0: // Writes to ROM, Inhibit
|
||||||
|
- BX_DEBUG(("Write to ROM ignored: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
|
||||||
|
+ if ((a20addr & 0xfffe0000) == 0x000e0000) {
|
||||||
|
+ BX_DEBUG(("Write to ROM ignored: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
|
||||||
|
+ } else {
|
||||||
|
+ BX_MEM_THIS rom[(a20addr & EXROM_MASK) + BIOSROMSZ] = *data_ptr;
|
||||||
|
+ }
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#!gpxe
|
||||||
|
dhcp net0
|
||||||
|
imgload img1
|
||||||
|
boot img1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!gpxe
|
||||||
|
ifopen net0
|
||||||
|
set net0/ip 10.0.2.15
|
||||||
|
set net0/netmask 255.255.255.0
|
||||||
|
set net0/gateway 10.0.2.2
|
||||||
|
set net0/dns 10.0.2.3
|
||||||
|
kernel http://etherboot.org/gtest/gtest.gpxe
|
||||||
|
boot gtest.gpxe
|
||||||
+87
-122
@@ -1,19 +1,17 @@
|
|||||||
# Location to place generated files
|
###############################################################################
|
||||||
#
|
#
|
||||||
BIN := bin
|
# Initialise various variables
|
||||||
|
|
||||||
# Initialise variables that get added to throughout the various Makefiles
|
|
||||||
#
|
#
|
||||||
MAKEDEPS := Makefile .toolcheck .echocheck
|
|
||||||
SRCDIRS :=
|
|
||||||
SRCS :=
|
|
||||||
NON_AUTO_SRCS :=
|
|
||||||
DRIVERS :=
|
|
||||||
ROMS :=
|
|
||||||
MEDIA :=
|
|
||||||
NON_AUTO_MEDIA :=
|
|
||||||
|
|
||||||
# Locations of utilities
|
CLEANUP :=
|
||||||
|
CFLAGS :=
|
||||||
|
ASFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
MAKEDEPS := Makefile
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Locations of tools
|
||||||
#
|
#
|
||||||
HOST_CC := gcc
|
HOST_CC := gcc
|
||||||
RM := rm -f
|
RM := rm -f
|
||||||
@@ -24,7 +22,7 @@ ECHO := echo
|
|||||||
PRINTF := printf
|
PRINTF := printf
|
||||||
PERL := /usr/bin/perl
|
PERL := /usr/bin/perl
|
||||||
CC := $(CROSS_COMPILE)gcc
|
CC := $(CROSS_COMPILE)gcc
|
||||||
CPP := $(CROSS_COMPILE)gcc -E -Wp,-Wall
|
CPP := $(CC) -E
|
||||||
AS := $(CROSS_COMPILE)as
|
AS := $(CROSS_COMPILE)as
|
||||||
LD := $(CROSS_COMPILE)ld
|
LD := $(CROSS_COMPILE)ld
|
||||||
SIZE := $(CROSS_COMPILE)size
|
SIZE := $(CROSS_COMPILE)size
|
||||||
@@ -35,123 +33,41 @@ NM := $(CROSS_COMPILE)nm
|
|||||||
OBJDUMP := $(CROSS_COMPILE)objdump
|
OBJDUMP := $(CROSS_COMPILE)objdump
|
||||||
PARSEROM := $(PERL) ./util/parserom.pl
|
PARSEROM := $(PERL) ./util/parserom.pl
|
||||||
MAKEROM := $(PERL) ./util/makerom.pl
|
MAKEROM := $(PERL) ./util/makerom.pl
|
||||||
MKCONFIG := $(PERL) ./util/mkconfig.pl
|
|
||||||
SYMCHECK := $(PERL) ./util/symcheck.pl
|
SYMCHECK := $(PERL) ./util/symcheck.pl
|
||||||
SORTOBJDUMP := $(PERL) ./util/sortobjdump.pl
|
SORTOBJDUMP := $(PERL) ./util/sortobjdump.pl
|
||||||
|
PADIMG := $(PERL) ./util/padimg.pl
|
||||||
|
LICENCE := $(PERL) ./util/licence.pl
|
||||||
NRV2B := ./util/nrv2b
|
NRV2B := ./util/nrv2b
|
||||||
ZBIN := ./util/zbin
|
ZBIN := ./util/zbin
|
||||||
|
ELF2EFI32 := ./util/elf2efi32
|
||||||
|
ELF2EFI64 := ./util/elf2efi64
|
||||||
|
EFIROM := ./util/efirom
|
||||||
|
ICCFIX := ./util/iccfix
|
||||||
DOXYGEN := doxygen
|
DOXYGEN := doxygen
|
||||||
|
BINUTILS_DIR := /usr
|
||||||
|
BFD_DIR := $(BINUTILS_DIR)
|
||||||
|
|
||||||
# If invoked with no build target, print out a helpfully suggestive
|
###############################################################################
|
||||||
# message.
|
|
||||||
#
|
#
|
||||||
noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb $(BIN)/undionly.kpxe
|
|
||||||
@$(ECHO) '==========================================================='
|
|
||||||
@$(ECHO)
|
|
||||||
@$(ECHO) 'To create a bootable floppy, type'
|
|
||||||
@$(ECHO) ' cat $(BIN)/gpxe.dsk > /dev/fd0'
|
|
||||||
@$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
|
|
||||||
@$(ECHO) 'data already on the disk.'
|
|
||||||
@$(ECHO)
|
|
||||||
@$(ECHO) 'To create a bootable USB key, type'
|
|
||||||
@$(ECHO) ' cat $(BIN)/gpxe.usb > /dev/sdX'
|
|
||||||
@$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
|
|
||||||
@$(ECHO) 'disk on your system. This will erase any data already on'
|
|
||||||
@$(ECHO) 'the USB key.'
|
|
||||||
@$(ECHO)
|
|
||||||
@$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
|
|
||||||
@$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.'
|
|
||||||
@$(ECHO)
|
|
||||||
@$(ECHO) 'These images contain drivers for all supported cards. You'
|
|
||||||
@$(ECHO) 'can build more customised images, and ROM images, using'
|
|
||||||
@$(ECHO) ' make bin/<rom-name>.<output-format>'
|
|
||||||
@$(ECHO)
|
|
||||||
@$(ECHO) '==========================================================='
|
|
||||||
|
|
||||||
# If no architecture is specified in Config or on the command-line,
|
|
||||||
# use that of the build machine.
|
|
||||||
#
|
|
||||||
ARCH := $(shell uname -m | sed -e 's,i[3456789]86,i386,')
|
|
||||||
|
|
||||||
# handle x86_64 like i386, but set -m32 option for 32bit code only
|
|
||||||
ifeq ($(ARCH),x86_64)
|
|
||||||
ARCH := i386
|
|
||||||
CFLAGS += -m32
|
|
||||||
ASFLAGS += --32
|
|
||||||
LDFLAGS += -m elf_i386
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Drag in architecture-specific Config
|
|
||||||
#
|
|
||||||
MAKEDEPS += arch/$(ARCH)/Config
|
|
||||||
include arch/$(ARCH)/Config
|
|
||||||
|
|
||||||
# Common flags
|
|
||||||
#
|
|
||||||
CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
|
|
||||||
CFLAGS += -Os -ffreestanding
|
|
||||||
CFLAGS += -Wall -W
|
|
||||||
CFLAGS += -g
|
|
||||||
CFLAGS += $(EXTRA_CFLAGS)
|
|
||||||
ASFLAGS += $(EXTRA_ASFLAGS)
|
|
||||||
LDFLAGS += $(EXTRA_LDFLAGS)
|
|
||||||
|
|
||||||
# Embedded image, if present
|
|
||||||
#
|
|
||||||
EMBEDDED_IMAGE = /dev/null
|
|
||||||
|
|
||||||
ifneq ($(NO_WERROR),1)
|
|
||||||
CFLAGS += -Werror
|
|
||||||
endif
|
|
||||||
|
|
||||||
# CFLAGS for specific object types
|
|
||||||
#
|
|
||||||
CFLAGS_c +=
|
|
||||||
CFLAGS_S += -DASSEMBLY
|
|
||||||
|
|
||||||
# Base object name of the current target
|
|
||||||
#
|
|
||||||
OBJECT = $(firstword $(subst ., ,$(@F)))
|
|
||||||
|
|
||||||
# CFLAGS for specific object files. You can define
|
|
||||||
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
|
|
||||||
# compiling bin/rtl8139.o.
|
|
||||||
#
|
|
||||||
OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
|
|
||||||
$(BIN)/%.flags :
|
|
||||||
@$(ECHO) $(OBJ_CFLAGS)
|
|
||||||
|
|
||||||
# Rules for specific object types.
|
|
||||||
#
|
|
||||||
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
|
|
||||||
RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
|
|
||||||
RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
|
|
||||||
RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
|
|
||||||
RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
|
|
||||||
|
|
||||||
PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
|
|
||||||
ASSEMBLE_S = $(AS) $(ASFLAGS)
|
|
||||||
RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
|
|
||||||
RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
|
|
||||||
|
|
||||||
DEBUG_TARGETS += dbg%.o c s
|
|
||||||
|
|
||||||
# SRCDIRS lists all directories containing source files.
|
# SRCDIRS lists all directories containing source files.
|
||||||
#
|
#
|
||||||
|
SRCDIRS :=
|
||||||
SRCDIRS += libgcc
|
SRCDIRS += libgcc
|
||||||
SRCDIRS += core
|
SRCDIRS += core
|
||||||
SRCDIRS += proto
|
SRCDIRS += proto
|
||||||
SRCDIRS += net net/tcp net/udp
|
SRCDIRS += net net/tcp net/udp net/infiniband net/80211
|
||||||
SRCDIRS += image
|
SRCDIRS += image
|
||||||
SRCDIRS += drivers/bus
|
SRCDIRS += drivers/bus
|
||||||
SRCDIRS += drivers/net
|
SRCDIRS += drivers/net
|
||||||
SRCDIRS += drivers/net/e1000
|
SRCDIRS += drivers/net/e1000
|
||||||
SRCDIRS += drivers/net/phantom
|
SRCDIRS += drivers/net/phantom
|
||||||
|
SRCDIRS += drivers/net/rtl818x
|
||||||
|
SRCDIRS += drivers/net/ath5k
|
||||||
SRCDIRS += drivers/block
|
SRCDIRS += drivers/block
|
||||||
SRCDIRS += drivers/nvs
|
SRCDIRS += drivers/nvs
|
||||||
SRCDIRS += drivers/bitbash
|
SRCDIRS += drivers/bitbash
|
||||||
SRCDIRS += drivers/infiniband
|
SRCDIRS += drivers/infiniband
|
||||||
SRCDIRS += interface/pxe
|
SRCDIRS += interface/pxe interface/efi interface/smbios
|
||||||
SRCDIRS += tests
|
SRCDIRS += tests
|
||||||
SRCDIRS += crypto crypto/axtls crypto/matrixssl
|
SRCDIRS += crypto crypto/axtls crypto/matrixssl
|
||||||
SRCDIRS += hci hci/commands hci/tui
|
SRCDIRS += hci hci/commands hci/tui
|
||||||
@@ -161,25 +77,74 @@ SRCDIRS += usr
|
|||||||
# NON_AUTO_SRCS lists files that are excluded from the normal
|
# NON_AUTO_SRCS lists files that are excluded from the normal
|
||||||
# automatic build system.
|
# automatic build system.
|
||||||
#
|
#
|
||||||
NON_AUTO_SRCS += core/elf_loader.c
|
NON_AUTO_SRCS :=
|
||||||
NON_AUTO_SRCS += drivers/net/prism2.c
|
NON_AUTO_SRCS += drivers/net/prism2.c
|
||||||
|
|
||||||
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
|
# INCDIRS lists the include path
|
||||||
# the automatic build system and varies by target; it includes the
|
|
||||||
# "-p 0x1234,0x5678" string to set the PCI IDs.
|
|
||||||
#
|
#
|
||||||
FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
|
INCDIRS :=
|
||||||
-i$(IDENT) -s 0 $@
|
INCDIRS += include .
|
||||||
|
|
||||||
# Some ROMs require specific flags to be passed to makerom.pl
|
###############################################################################
|
||||||
#
|
#
|
||||||
MAKEROM_FLAGS_3c503 = -3
|
# Default build target: build the most common targets and print out a
|
||||||
|
# helpfully suggestive message
|
||||||
|
#
|
||||||
|
all : bin/blib.a bin/gpxe.dsk bin/gpxe.iso bin/gpxe.usb bin/undionly.kpxe
|
||||||
|
@$(ECHO) '==========================================================='
|
||||||
|
@$(ECHO)
|
||||||
|
@$(ECHO) 'To create a bootable floppy, type'
|
||||||
|
@$(ECHO) ' cat bin/gpxe.dsk > /dev/fd0'
|
||||||
|
@$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
|
||||||
|
@$(ECHO) 'data already on the disk.'
|
||||||
|
@$(ECHO)
|
||||||
|
@$(ECHO) 'To create a bootable USB key, type'
|
||||||
|
@$(ECHO) ' cat bin/gpxe.usb > /dev/sdX'
|
||||||
|
@$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
|
||||||
|
@$(ECHO) 'disk on your system. This will erase any data already on'
|
||||||
|
@$(ECHO) 'the USB key.'
|
||||||
|
@$(ECHO)
|
||||||
|
@$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
|
||||||
|
@$(ECHO) 'bin/gpxe.iso to a blank CD-ROM.'
|
||||||
|
@$(ECHO)
|
||||||
|
@$(ECHO) 'These images contain drivers for all supported cards. You'
|
||||||
|
@$(ECHO) 'can build more customised images, and ROM images, using'
|
||||||
|
@$(ECHO) ' make bin/<rom-name>.<output-format>'
|
||||||
|
@$(ECHO)
|
||||||
|
@$(ECHO) '==========================================================='
|
||||||
|
|
||||||
# Drag in architecture-specific Makefile
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Build targets that do nothing but might be tried by users
|
||||||
|
#
|
||||||
|
configure :
|
||||||
|
@$(ECHO) "No configuration needed."
|
||||||
|
|
||||||
|
install :
|
||||||
|
@$(ECHO) "No installation required."
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Version number calculations
|
||||||
|
#
|
||||||
|
VERSION_MAJOR = 0
|
||||||
|
VERSION_MINOR = 9
|
||||||
|
VERSION_PATCH = 9
|
||||||
|
EXTRAVERSION =
|
||||||
|
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
|
||||||
|
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
|
||||||
|
CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \
|
||||||
|
-DVERSION_MINOR=$(VERSION_MINOR) \
|
||||||
|
-DVERSION_PATCH=$(VERSION_PATCH) \
|
||||||
|
-DVERSION=\"$(VERSION)\"
|
||||||
|
IDENT = '$(@F) $(VERSION) (GPL) etherboot.org'
|
||||||
|
version :
|
||||||
|
@$(ECHO) $(VERSION)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Drag in the bulk of the build system
|
||||||
#
|
#
|
||||||
MAKEDEPS += arch/$(ARCH)/Makefile
|
|
||||||
include arch/$(ARCH)/Makefile
|
|
||||||
|
|
||||||
# Drag in the automatic build system and other housekeeping functions
|
|
||||||
MAKEDEPS += Makefile.housekeeping
|
MAKEDEPS += Makefile.housekeeping
|
||||||
include Makefile.housekeeping
|
include Makefile.housekeeping
|
||||||
|
|||||||
+538
-140
@@ -1,50 +1,10 @@
|
|||||||
# -*- makefile -*- : Force emacs to use Makefile mode
|
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||||
|
#
|
||||||
# This file contains various boring housekeeping functions that would
|
# This file contains various boring housekeeping functions that would
|
||||||
# otherwise seriously clutter up the main Makefile.
|
# otherwise seriously clutter up the main Makefile.
|
||||||
|
|
||||||
# Objects to be removed by "make clean"
|
###############################################################################
|
||||||
#
|
#
|
||||||
CLEANUP := $(BIN)/*.* # *.* to avoid catching the "CVS" directory
|
|
||||||
|
|
||||||
# Version number calculations
|
|
||||||
#
|
|
||||||
VERSION_MAJOR = 0
|
|
||||||
VERSION_MINOR = 9
|
|
||||||
VERSION_PATCH = 5
|
|
||||||
EXTRAVERSION =
|
|
||||||
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
|
|
||||||
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
|
|
||||||
CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \
|
|
||||||
-DVERSION_MINOR=$(VERSION_MINOR) \
|
|
||||||
-DVERSION=\"$(VERSION)\"
|
|
||||||
IDENT = '$(@F) $(VERSION) (GPL) etherboot.org'
|
|
||||||
version :
|
|
||||||
@$(ECHO) $(VERSION)
|
|
||||||
|
|
||||||
configure :
|
|
||||||
@$(ECHO) "No configuration needed."
|
|
||||||
|
|
||||||
install :
|
|
||||||
@$(ECHO) "No installation required. Generated images will be placed in the" $(BIN) "directory."
|
|
||||||
|
|
||||||
# Check for tools that can cause failed builds
|
|
||||||
#
|
|
||||||
.toolcheck : Makefile
|
|
||||||
@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
|
|
||||||
$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
|
|
||||||
$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
|
|
||||||
$(ECHO) 'Your Perl version has a Unicode handling bug'; \
|
|
||||||
$(ECHO) 'Execute this command before compiling Etherboot:'; \
|
|
||||||
$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
@$(TOUCH) $@
|
|
||||||
VERYCLEANUP += .toolcheck
|
|
||||||
|
|
||||||
# Find a usable "echo -e" substitute.
|
# Find a usable "echo -e" substitute.
|
||||||
#
|
#
|
||||||
TAB := $(shell $(PRINTF) '\t')
|
TAB := $(shell $(PRINTF) '\t')
|
||||||
@@ -86,20 +46,75 @@ else
|
|||||||
@$(ECHO) "No usable \"echo -e\" substitute found"
|
@$(ECHO) "No usable \"echo -e\" substitute found"
|
||||||
@exit 1
|
@exit 1
|
||||||
endif
|
endif
|
||||||
|
MAKEDEPS += .echocheck
|
||||||
VERYCLEANUP += .echocheck
|
VERYCLEANUP += .echocheck
|
||||||
|
|
||||||
echo :
|
echo :
|
||||||
@$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
|
@$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
|
||||||
|
|
||||||
# Build verbosity
|
###############################################################################
|
||||||
#
|
#
|
||||||
ifeq ($(V),1)
|
# Generate a usable "seq" substitute
|
||||||
Q =
|
#
|
||||||
QM = @\#
|
define seq
|
||||||
|
$(shell awk 'BEGIN { for ( i = $(1) ; i <= $(2) ; i++ ) print i }')
|
||||||
|
endef
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Determine host OS
|
||||||
|
#
|
||||||
|
HOST_OS := $(shell uname -s)
|
||||||
|
hostos :
|
||||||
|
@$(ECHO) $(HOST_OS)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Determine compiler
|
||||||
|
|
||||||
|
CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | cut -d" " -f2)
|
||||||
|
ccdefs:
|
||||||
|
@$(ECHO) $(CCDEFS)
|
||||||
|
|
||||||
|
ifeq ($(filter __ICC,$(CCDEFS)),__ICC)
|
||||||
|
CCTYPE := icc
|
||||||
else
|
else
|
||||||
Q = @
|
CCTYPE := gcc
|
||||||
QM = @
|
|
||||||
endif
|
endif
|
||||||
|
cctype:
|
||||||
|
@$(ECHO) $(CCTYPE)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Check for tools that can cause failed builds
|
||||||
|
#
|
||||||
|
.toolcheck :
|
||||||
|
@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
|
||||||
|
$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
|
||||||
|
$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
|
||||||
|
$(ECHO) 'Your Perl version has a Unicode handling bug'; \
|
||||||
|
$(ECHO) 'Execute this command before compiling Etherboot:'; \
|
||||||
|
$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@$(TOUCH) $@
|
||||||
|
MAKEDEPS += .toolcheck
|
||||||
|
VERYCLEANUP += .toolcheck
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Check for various tool workarounds
|
||||||
|
#
|
||||||
|
|
||||||
|
# Make syntax does not allow use of comma or space in certain places.
|
||||||
|
# This ugly workaround is suggested in the manual.
|
||||||
|
#
|
||||||
|
COMMA := ,
|
||||||
|
EMPTY :=
|
||||||
|
SPACE := $(EMPTY) $(EMPTY)
|
||||||
|
|
||||||
# Check for an old version of gas (binutils 2.9.1)
|
# Check for an old version of gas (binutils 2.9.1)
|
||||||
#
|
#
|
||||||
@@ -112,18 +127,179 @@ oldgas :
|
|||||||
# default, even when -ffreestanding is specified. We therefore need
|
# default, even when -ffreestanding is specified. We therefore need
|
||||||
# to disable -fstack-protector if the compiler supports it.
|
# to disable -fstack-protector if the compiler supports it.
|
||||||
#
|
#
|
||||||
SP_TEST = $(CC) -fno-stack-protector -x c -E - < /dev/null >/dev/null 2>&1
|
ifeq ($(CCTYPE),gcc)
|
||||||
|
SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
|
||||||
|
-o /dev/null >/dev/null 2>&1
|
||||||
SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
|
SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
|
||||||
CFLAGS += $(SP_FLAGS)
|
CFLAGS += $(SP_FLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
# compiler.h is needed for our linking and debugging system
|
# gcc 4.4 generates .eh_frame sections by default, which distort the
|
||||||
|
# output of "size". Inhibit this.
|
||||||
#
|
#
|
||||||
CFLAGS += -include compiler.h
|
ifeq ($(CCTYPE),gcc)
|
||||||
|
CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -x c -c /dev/null \
|
||||||
|
-o /dev/null >/dev/null 2>&1
|
||||||
|
CFI_FLAGS := $(shell $(CFI_TEST) && $(ECHO) '-fno-dwarf2-cfi-asm')
|
||||||
|
CFLAGS += $(CFI_FLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
# config/%.h files are generated from config.h using mkconfig.pl
|
# Some versions of gas choke on division operators, treating them as
|
||||||
config/%.h : config*.h
|
# comment markers. Specifying --divide will work around this problem,
|
||||||
$(MKCONFIG) config.h
|
# but isn't available on older gas versions.
|
||||||
CLEANUP += config/*.h
|
#
|
||||||
|
DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
|
||||||
|
DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
|
||||||
|
ASFLAGS += $(DIVIDE_FLAGS)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Build verbosity
|
||||||
|
#
|
||||||
|
ifeq ($(V),1)
|
||||||
|
Q :=
|
||||||
|
QM := @\#
|
||||||
|
else
|
||||||
|
Q := @
|
||||||
|
QM := @
|
||||||
|
endif
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Set BIN according to whatever was specified on the command line as
|
||||||
|
# the build target.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Determine how many different BIN directories are mentioned in the
|
||||||
|
# make goals.
|
||||||
|
#
|
||||||
|
BIN_GOALS := $(filter bin/% bin-%,$(MAKECMDGOALS))
|
||||||
|
BIN_GOAL_BINS := $(foreach BG,$(BIN_GOALS),$(firstword $(subst /, ,$(BG))))
|
||||||
|
NUM_BINS := $(words $(sort $(BIN_GOAL_BINS)))
|
||||||
|
|
||||||
|
ifeq ($(NUM_BINS),0)
|
||||||
|
|
||||||
|
# No BIN directory was specified. Set BIN to "bin" as a sensible
|
||||||
|
# default.
|
||||||
|
|
||||||
|
BIN := bin
|
||||||
|
|
||||||
|
else # NUM_BINS == 0
|
||||||
|
|
||||||
|
ifeq ($(NUM_BINS),1)
|
||||||
|
|
||||||
|
# If exactly one BIN directory was specified, set BIN to match this
|
||||||
|
# directory.
|
||||||
|
#
|
||||||
|
BIN := $(firstword $(BIN_GOAL_BINS))
|
||||||
|
|
||||||
|
else # NUM_BINS == 1
|
||||||
|
|
||||||
|
# More than one BIN directory was specified. We cannot handle the
|
||||||
|
# latter case within a single make invocation, so set up recursive
|
||||||
|
# targets for each BIN directory.
|
||||||
|
#
|
||||||
|
# Leave $(BIN) undefined. This has implications for any target that
|
||||||
|
# depends on $(BIN); such targets should be made conditional upon the
|
||||||
|
# existence of $(BIN).
|
||||||
|
#
|
||||||
|
$(BIN_GOALS) : % : BIN_RECURSE
|
||||||
|
$(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) $@
|
||||||
|
.PHONY : BIN_RECURSE
|
||||||
|
|
||||||
|
endif # NUM_BINS == 1
|
||||||
|
endif # NUM_BINS == 0
|
||||||
|
|
||||||
|
ifdef BIN
|
||||||
|
|
||||||
|
# Create $(BIN) directory if it doesn't exist yet
|
||||||
|
#
|
||||||
|
ifeq ($(wildcard $(BIN)),)
|
||||||
|
$(shell $(MKDIR) -p $(BIN))
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Target to allow e.g. "make bin-efi arch"
|
||||||
|
#
|
||||||
|
$(BIN) :
|
||||||
|
@# Do nothing, silently
|
||||||
|
.PHONY : $(BIN)
|
||||||
|
|
||||||
|
# Remove everything in $(BIN) for a "make clean"
|
||||||
|
#
|
||||||
|
CLEANUP += $(BIN)/*.* # Avoid picking up directories
|
||||||
|
|
||||||
|
endif # defined(BIN)
|
||||||
|
|
||||||
|
# Determine whether or not we need to include the dependency files
|
||||||
|
#
|
||||||
|
NO_DEP_TARGETS := $(BIN) clean veryclean
|
||||||
|
ifeq ($(MAKECMDGOALS),)
|
||||||
|
NEED_DEPS := 1
|
||||||
|
endif
|
||||||
|
ifneq ($(strip $(filter-out $(NO_DEP_TARGETS),$(MAKECMDGOALS))),)
|
||||||
|
NEED_DEPS := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Select build architecture and platform based on $(BIN)
|
||||||
|
#
|
||||||
|
# BIN has the form bin[-[arch-]platform]
|
||||||
|
|
||||||
|
ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
|
||||||
|
PLATFORMS := $(patsubst config/defaults/%.h,%,\
|
||||||
|
$(wildcard config/defaults/*.h))
|
||||||
|
archs :
|
||||||
|
@$(ECHO) $(ARCHS)
|
||||||
|
|
||||||
|
platforms :
|
||||||
|
@$(ECHO) $(PLATFORMS)
|
||||||
|
|
||||||
|
ifdef BIN
|
||||||
|
|
||||||
|
# Determine architecture portion of $(BIN), if present
|
||||||
|
BIN_ARCH := $(strip $(foreach A,$(ARCHS),\
|
||||||
|
$(patsubst bin-$(A)-%,$(A),\
|
||||||
|
$(filter bin-$(A)-%,$(BIN)))))
|
||||||
|
|
||||||
|
# Determine platform portion of $(BIN), if present
|
||||||
|
ifeq ($(BIN_ARCH),)
|
||||||
|
BIN_PLATFORM := $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
|
||||||
|
else
|
||||||
|
BIN_PLATFORM := $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Determine build architecture
|
||||||
|
DEFAULT_ARCH := i386
|
||||||
|
ARCH := $(firstword $(BIN_ARCH) $(DEFAULT_ARCH))
|
||||||
|
CFLAGS += -DARCH=$(ARCH)
|
||||||
|
arch :
|
||||||
|
@$(ECHO) $(ARCH)
|
||||||
|
.PHONY : arch
|
||||||
|
|
||||||
|
# Determine build platform
|
||||||
|
DEFAULT_PLATFORM := pcbios
|
||||||
|
PLATFORM := $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
|
||||||
|
CFLAGS += -DPLATFORM=$(PLATFORM)
|
||||||
|
platform :
|
||||||
|
@$(ECHO) $(PLATFORM)
|
||||||
|
|
||||||
|
endif # defined(BIN)
|
||||||
|
|
||||||
|
# Include architecture-specific Makefile
|
||||||
|
ifdef ARCH
|
||||||
|
MAKEDEPS += arch/$(ARCH)/Makefile
|
||||||
|
include arch/$(ARCH)/Makefile
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Include architecture-specific include path
|
||||||
|
ifdef ARCH
|
||||||
|
INCDIRS += arch/$(ARCH)/include
|
||||||
|
endif
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Source file handling
|
||||||
|
|
||||||
# SRCDIRS lists all directories containing source files.
|
# SRCDIRS lists all directories containing source files.
|
||||||
srcdirs :
|
srcdirs :
|
||||||
@@ -144,6 +320,107 @@ AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
|
|||||||
autosrcs :
|
autosrcs :
|
||||||
@$(ECHO) $(AUTO_SRCS)
|
@$(ECHO) $(AUTO_SRCS)
|
||||||
|
|
||||||
|
# Just about everything else in this section depends upon having
|
||||||
|
# $(BIN) set
|
||||||
|
|
||||||
|
ifdef BIN
|
||||||
|
|
||||||
|
# INCDIRS lists the include path
|
||||||
|
incdirs :
|
||||||
|
@$(ECHO) $(INCDIRS)
|
||||||
|
|
||||||
|
# Common flags
|
||||||
|
#
|
||||||
|
CFLAGS += $(foreach INC,$(INCDIRS),-I$(INC))
|
||||||
|
CFLAGS += -Os
|
||||||
|
CFLAGS += -g
|
||||||
|
ifeq ($(CCTYPE),gcc)
|
||||||
|
CFLAGS += -ffreestanding
|
||||||
|
CFLAGS += -Wall -W -Wformat-nonliteral
|
||||||
|
endif
|
||||||
|
ifeq ($(CCTYPE),icc)
|
||||||
|
CFLAGS += -fno-builtin
|
||||||
|
CFLAGS += -no-ip
|
||||||
|
CFLAGS += -no-gcc
|
||||||
|
CFLAGS += -diag-disable 111 # Unreachable code
|
||||||
|
CFLAGS += -diag-disable 128 # Unreachable loop
|
||||||
|
CFLAGS += -diag-disable 170 # Array boundary checks
|
||||||
|
CFLAGS += -diag-disable 177 # Unused functions
|
||||||
|
CFLAGS += -diag-disable 181 # printf() format checks
|
||||||
|
CFLAGS += -diag-disable 188 # enum strictness
|
||||||
|
CFLAGS += -diag-disable 193 # Undefined preprocessor identifiers
|
||||||
|
CFLAGS += -diag-disable 280 # switch ( constant )
|
||||||
|
CFLAGS += -diag-disable 310 # K&R parameter lists
|
||||||
|
CFLAGS += -diag-disable 424 # Extra semicolon
|
||||||
|
CFLAGS += -diag-disable 589 # Declarations mid-code
|
||||||
|
CFLAGS += -diag-disable 593 # Unused variables
|
||||||
|
CFLAGS += -diag-disable 810 # Casting ints to smaller ints
|
||||||
|
CFLAGS += -diag-disable 981 # Sequence point violations
|
||||||
|
CFLAGS += -diag-disable 1292 # Ignored attributes
|
||||||
|
CFLAGS += -diag-disable 1338 # void pointer arithmetic
|
||||||
|
CFLAGS += -diag-disable 1361 # Variable-length arrays
|
||||||
|
CFLAGS += -diag-disable 1418 # Missing prototypes
|
||||||
|
CFLAGS += -diag-disable 1419 # Missing prototypes
|
||||||
|
CFLAGS += -diag-disable 1599 # Hidden variables
|
||||||
|
CFLAGS += -Wall -Wmissing-declarations
|
||||||
|
endif
|
||||||
|
CFLAGS += $(EXTRA_CFLAGS)
|
||||||
|
ASFLAGS += $(EXTRA_ASFLAGS)
|
||||||
|
LDFLAGS += $(EXTRA_LDFLAGS)
|
||||||
|
|
||||||
|
# Inhibit -Werror if NO_WERROR is specified on make command line
|
||||||
|
#
|
||||||
|
ifneq ($(NO_WERROR),1)
|
||||||
|
CFLAGS += -Werror
|
||||||
|
ASFLAGS += --fatal-warnings
|
||||||
|
endif
|
||||||
|
|
||||||
|
# compiler.h is needed for our linking and debugging system
|
||||||
|
#
|
||||||
|
CFLAGS += -include compiler.h
|
||||||
|
|
||||||
|
# CFLAGS for specific object types
|
||||||
|
#
|
||||||
|
CFLAGS_c +=
|
||||||
|
CFLAGS_S += -DASSEMBLY
|
||||||
|
|
||||||
|
# Base object name of the current target
|
||||||
|
#
|
||||||
|
OBJECT = $(firstword $(subst ., ,$(@F)))
|
||||||
|
|
||||||
|
# CFLAGS for specific object files. You can define
|
||||||
|
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
|
||||||
|
# compiling bin/rtl8139.o.
|
||||||
|
#
|
||||||
|
OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
|
||||||
|
$(BIN)/%.flags :
|
||||||
|
@$(ECHO) $(OBJ_CFLAGS)
|
||||||
|
|
||||||
|
# ICC requires postprocessing objects to fix up table alignments
|
||||||
|
#
|
||||||
|
ifeq ($(CCTYPE),icc)
|
||||||
|
POST_O = && $(ICCFIX) $@
|
||||||
|
POST_O_DEPS := $(ICCFIX)
|
||||||
|
else
|
||||||
|
POST_O :=
|
||||||
|
POST_O_DEPS :=
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Rules for specific object types.
|
||||||
|
#
|
||||||
|
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
|
||||||
|
RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O)
|
||||||
|
RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(subst -,_,$(OBJECT))=$* -c $< -o $@ $(POST_O)
|
||||||
|
RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
|
||||||
|
RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
|
||||||
|
|
||||||
|
PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
|
||||||
|
ASSEMBLE_S = $(AS) $(ASFLAGS)
|
||||||
|
RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
|
||||||
|
RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
|
||||||
|
|
||||||
|
DEBUG_TARGETS += dbg%.o c s
|
||||||
|
|
||||||
# We automatically generate rules for any file mentioned in AUTO_SRCS
|
# We automatically generate rules for any file mentioned in AUTO_SRCS
|
||||||
# using the following set of templates. It would be cleaner to use
|
# using the following set of templates. It would be cleaner to use
|
||||||
# $(eval ...), but this function exists only in GNU make >= 3.80.
|
# $(eval ...), but this function exists only in GNU make >= 3.80.
|
||||||
@@ -157,43 +434,29 @@ autosrcs :
|
|||||||
#
|
#
|
||||||
define src_template
|
define src_template
|
||||||
|
|
||||||
@$(ECHO) "Generating Makefile rules for $(1)"
|
@$(ECHO) " [DEPS] $(1)"
|
||||||
@$(MKDIR) -p $(dir $(2))
|
@$(MKDIR) -p $(dir $(2))
|
||||||
@$(RM) $(2)
|
@$(RM) $(2)
|
||||||
@$(TOUCH) $(2)
|
@$(TOUCH) $(2)
|
||||||
$(foreach OBJ,$(if $(OBJS_$(4)),$(OBJS_$(4)),$(4)), \
|
|
||||||
$(call obj_template,$(1),$(2),$(3),$(OBJ)))
|
|
||||||
@$(PARSEROM) $(1) >> $(2)
|
|
||||||
|
|
||||||
endef
|
|
||||||
|
|
||||||
# obj_template : generate Makefile rules for a given resultant object
|
|
||||||
# of a particular source file. (We can have multiple objects per
|
|
||||||
# source file via the OBJS_xxx list.)
|
|
||||||
#
|
|
||||||
# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
|
|
||||||
# $(2) is the full path to the .d file (e.g. "bin/deps/drivers/net/rtl8139.d")
|
|
||||||
# $(3) is the source type (e.g. "c")
|
|
||||||
# $(4) is the object name (e.g. "rtl8139")
|
|
||||||
#
|
|
||||||
define obj_template
|
|
||||||
|
|
||||||
@$(CPP) $(CFLAGS) $(CFLAGS_$(3)) $(CFLAGS_$(4)) -DOBJECT=$(4) \
|
@$(CPP) $(CFLAGS) $(CFLAGS_$(3)) $(CFLAGS_$(4)) -DOBJECT=$(4) \
|
||||||
-Wno-error -MM $(1) -MT "$(4)_DEPS" -MG -MP | \
|
-Wno-error -MM $(1) -MG -MP | \
|
||||||
sed 's/_DEPS\s*:/_DEPS =/' >> $(2)
|
sed 's/\.o\s*:/_DEPS =/' >> $(2)
|
||||||
@$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
|
@$(ECHO_E) '\n$$(BIN)/$(4).o :' \
|
||||||
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \
|
'$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \
|
||||||
|
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
|
||||||
'\n\t$$(RULE_$(3))\n' \
|
'\n\t$$(RULE_$(3))\n' \
|
||||||
'\nBOBJS += $$(BIN)/$(4).o\n' \
|
'\nBOBJS += $$(BIN)/$(4).o\n' \
|
||||||
$(foreach TGT,$(DEBUG_TARGETS), \
|
$(foreach TGT,$(DEBUG_TARGETS), \
|
||||||
$(if $(RULE_$(3)_to_$(TGT)), \
|
$(if $(RULE_$(3)_to_$(TGT)), \
|
||||||
'\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
|
'\n$$(BIN)/$(4).$(TGT) :' \
|
||||||
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \
|
'$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \
|
||||||
|
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
|
||||||
'\n\t$$(RULE_$(3)_to_$(TGT))\n' \
|
'\n\t$$(RULE_$(3)_to_$(TGT))\n' \
|
||||||
'\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
|
'\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
|
||||||
'\n$(2) : $$($(4)_DEPS)\n' \
|
'\n$(2) : $$($(4)_DEPS)\n' \
|
||||||
'\nTAGS : $$($(4)_DEPS)\n' \
|
'\nTAGS : $$($(4)_DEPS)\n' \
|
||||||
>> $(2)
|
>> $(2)
|
||||||
|
@$(PARSEROM) $(1) >> $(2)
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
@@ -205,7 +468,11 @@ $(BIN)/deps/%.d : % $(MAKEDEPS) $(PARSEROM)
|
|||||||
# Calculate and include the list of Makefile rules files
|
# Calculate and include the list of Makefile rules files
|
||||||
#
|
#
|
||||||
AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
|
AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
|
||||||
|
ifdef NEED_DEPS
|
||||||
|
ifneq ($(AUTO_DEPS),)
|
||||||
-include $(AUTO_DEPS)
|
-include $(AUTO_DEPS)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
autodeps :
|
autodeps :
|
||||||
@$(ECHO) $(AUTO_DEPS)
|
@$(ECHO) $(AUTO_DEPS)
|
||||||
VERYCLEANUP += $(BIN)/deps
|
VERYCLEANUP += $(BIN)/deps
|
||||||
@@ -220,13 +487,31 @@ drivers :
|
|||||||
roms :
|
roms :
|
||||||
@$(ECHO) $(ROMS)
|
@$(ECHO) $(ROMS)
|
||||||
|
|
||||||
# Embedded binary
|
# List of embedded images included in the last build of embedded.o.
|
||||||
$(BIN)/embedimg.bin: $(EMBEDDED_IMAGE)
|
# This is needed in order to correctly rebuild embedded.o whenever the
|
||||||
$(QM)$(ECHO) " [COPY] $@"
|
# list of objects changes.
|
||||||
$(Q)$(CP) -f $(EMBEDDED_IMAGE) $@
|
#
|
||||||
|
EMBEDDED_LIST := $(BIN)/.embedded.list
|
||||||
|
ifeq ($(wildcard $(EMBEDDED_LIST)),)
|
||||||
|
EMBEDDED_LIST_IMAGE := <invalid>
|
||||||
|
else
|
||||||
|
EMBEDDED_LIST_IMAGE := $(shell cat $(EMBEDDED_LIST))
|
||||||
|
endif
|
||||||
|
ifneq ($(EMBEDDED_LIST_IMAGE),$(EMBEDDED_IMAGE))
|
||||||
|
$(shell $(ECHO) "$(EMBEDDED_IMAGE)" > $(EMBEDDED_LIST))
|
||||||
|
endif
|
||||||
|
|
||||||
$(BIN)/embed.o: $(BIN)/embedimg.bin
|
$(EMBEDDED_LIST) :
|
||||||
CFLAGS_embed = -DEMBEDIMG=\"$(BIN)/embedimg.bin\"
|
|
||||||
|
VERYCLEANUP += $(EMBEDDED_LIST)
|
||||||
|
|
||||||
|
EMBEDDED_FILES := $(subst $(COMMA), ,$(EMBEDDED_IMAGE))
|
||||||
|
EMBED_ALL := $(foreach i,$(call seq,1,$(words $(EMBEDDED_FILES))),\
|
||||||
|
EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
|
||||||
|
\"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
|
||||||
|
|
||||||
|
$(BIN)/embedded.o : $(EMBEDDED_FILES) $(EMBEDDED_LIST)
|
||||||
|
CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
|
||||||
|
|
||||||
# Generate the NIC file from the parsed source files. The NIC file is
|
# Generate the NIC file from the parsed source files. The NIC file is
|
||||||
# only for rom-o-matic.
|
# only for rom-o-matic.
|
||||||
@@ -237,7 +522,7 @@ $(BIN)/NIC : $(AUTO_DEPS)
|
|||||||
'it is only for rom-o-matic' >> $@
|
'it is only for rom-o-matic' >> $@
|
||||||
@$(ECHO) >> $@
|
@$(ECHO) >> $@
|
||||||
@perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
|
@perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
|
||||||
CLEANUP += $(BIN)/NIC
|
CLEANUP += $(BIN)/NIC # Doesn't match the $(BIN)/*.* pattern
|
||||||
|
|
||||||
# Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
|
# Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
|
||||||
# derive the variables:
|
# derive the variables:
|
||||||
@@ -305,7 +590,6 @@ TGT_MAKEROM_FLAGS = $(strip $(MAKEROM_FLAGS_$(TGT_ROM_NAME)) \
|
|||||||
# Calculate list of debugging versions of objects to be included in
|
# Calculate list of debugging versions of objects to be included in
|
||||||
# the target.
|
# the target.
|
||||||
#
|
#
|
||||||
COMMA := ,
|
|
||||||
DEBUG_LIST = $(subst $(COMMA), ,$(DEBUG))
|
DEBUG_LIST = $(subst $(COMMA), ,$(DEBUG))
|
||||||
DEBUG_OBJ_LEVEL = $(firstword $(word 2,$(subst :, ,$(1))) 1)
|
DEBUG_OBJ_LEVEL = $(firstword $(word 2,$(subst :, ,$(1))) 1)
|
||||||
DEBUG_OBJ_BASE = $(word 1,$(subst :, ,$(1))).dbg$(call DEBUG_OBJ_LEVEL,$(1))
|
DEBUG_OBJ_BASE = $(word 1,$(subst :, ,$(1))).dbg$(call DEBUG_OBJ_LEVEL,$(1))
|
||||||
@@ -342,8 +626,13 @@ $(BIN)/%.info :
|
|||||||
# in order to correctly rebuild blib whenever the list of objects
|
# in order to correctly rebuild blib whenever the list of objects
|
||||||
# changes.
|
# changes.
|
||||||
#
|
#
|
||||||
BLIB_LIST = $(BIN)/.blib.list
|
BLIB_LIST := $(BIN)/.blib.list
|
||||||
ifneq ($(shell cat $(BLIB_LIST)),$(BLIB_OBJS))
|
ifeq ($(wildcard $(BLIB_LIST)),)
|
||||||
|
BLIB_LIST_OBJS := <invalid>
|
||||||
|
else
|
||||||
|
BLIB_LIST_OBJS := $(shell cat $(BLIB_LIST))
|
||||||
|
endif
|
||||||
|
ifneq ($(BLIB_LIST_OBJS),$(BLIB_OBJS))
|
||||||
$(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
|
$(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -378,6 +667,55 @@ $(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
|
|||||||
$(BIN)/%.map : $(BIN)/%.tmp
|
$(BIN)/%.map : $(BIN)/%.tmp
|
||||||
@less $(BIN)/$*.tmp.map
|
@less $(BIN)/$*.tmp.map
|
||||||
|
|
||||||
|
# Get objects list for the specified target
|
||||||
|
#
|
||||||
|
define objs_list
|
||||||
|
$(sort $(foreach OBJ_SYMBOL,\
|
||||||
|
$(filter obj_%,$(shell $(NM) $(1) | cut -d" " -f3)),\
|
||||||
|
$(patsubst obj_%,%,$(OBJ_SYMBOL))))
|
||||||
|
endef
|
||||||
|
$(BIN)/%.objs : $(BIN)/%.tmp
|
||||||
|
$(Q)$(ECHO) $(call objs_list,$<)
|
||||||
|
$(BIN)/%.sizes : $(BIN)/%.tmp
|
||||||
|
$(Q)$(SIZE) -t $(foreach OBJ,$(call objs_list,$<),$(BIN)/$(OBJ).o) | \
|
||||||
|
sort -g
|
||||||
|
|
||||||
|
# Get dependency list for the specified target
|
||||||
|
#
|
||||||
|
define deps_list
|
||||||
|
$(sort $(foreach OBJ,$(call objs_list,$(1)),$($(OBJ)_DEPS)))
|
||||||
|
endef
|
||||||
|
$(BIN)/%.deps : $(BIN)/%.tmp
|
||||||
|
$(Q)$(ECHO) $(call deps_list,$<)
|
||||||
|
|
||||||
|
# Get unneeded source files for the specified target
|
||||||
|
#
|
||||||
|
define nodeps_list
|
||||||
|
$(sort $(filter-out $(call deps_list,$(1)),\
|
||||||
|
$(foreach BOBJ,$(BOBJS),\
|
||||||
|
$($(basename $(notdir $(BOBJ)))_DEPS))))
|
||||||
|
endef
|
||||||
|
$(BIN)/%.nodeps : $(BIN)/%.tmp
|
||||||
|
$(Q)$(ECHO) $(call nodeps_list,$<)
|
||||||
|
|
||||||
|
# Get licensing verdict for the specified target
|
||||||
|
#
|
||||||
|
define unlicensed_deps_list
|
||||||
|
$(shell grep -L FILE_LICENCE $(call deps_list,$(1)))
|
||||||
|
endef
|
||||||
|
define licence_list
|
||||||
|
$(patsubst __licence_%,%,\
|
||||||
|
$(filter __licence_%,$(shell $(NM) $(1) | cut -d" " -f3)))
|
||||||
|
endef
|
||||||
|
$(BIN)/%.licence : $(BIN)/%.tmp
|
||||||
|
$(QM)$(ECHO) " [LICENCE] $@"
|
||||||
|
$(Q)$(if $(strip $(call unlicensed_deps_list,$<)),\
|
||||||
|
echo -n "Unable to determine licence because the following " ;\
|
||||||
|
echo "files are missing a licence declaration:" ;\
|
||||||
|
echo $(call unlicensed_deps_list,$<);\
|
||||||
|
exit 1,\
|
||||||
|
$(LICENCE) $(call licence_list,$<))
|
||||||
|
|
||||||
# Extract compression information from intermediate object file
|
# Extract compression information from intermediate object file
|
||||||
#
|
#
|
||||||
$(BIN)/%.zinfo : $(BIN)/%.tmp
|
$(BIN)/%.zinfo : $(BIN)/%.tmp
|
||||||
@@ -396,10 +734,6 @@ $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
|
|||||||
$(QM)$(ECHO) " [ZBIN] $@"
|
$(QM)$(ECHO) " [ZBIN] $@"
|
||||||
$(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
|
$(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
|
||||||
|
|
||||||
# Build bochs symbol table
|
|
||||||
$(BIN)/%.bxs : $(BIN)/%.tmp
|
|
||||||
$(NM) $< | cut -d" " -f1,3 > $@
|
|
||||||
|
|
||||||
# Rules for each media format. These are generated and placed in an
|
# Rules for each media format. These are generated and placed in an
|
||||||
# external Makefile fragment. We could do this via $(eval ...), but
|
# external Makefile fragment. We could do this via $(eval ...), but
|
||||||
# that would require make >= 3.80.
|
# that would require make >= 3.80.
|
||||||
@@ -435,13 +769,14 @@ automedia :
|
|||||||
#
|
#
|
||||||
define media_template
|
define media_template
|
||||||
|
|
||||||
@$(ECHO) "Generating Makefile rules for $(1) media"
|
@$(ECHO) " [MEDIADEPS] $(1)"
|
||||||
@$(MKDIR) -p $(dir $(2))
|
@$(MKDIR) -p $(dir $(2))
|
||||||
@$(RM) $(2)
|
@$(RM) $(2)
|
||||||
@$(TOUCH) $(2)
|
@$(TOUCH) $(2)
|
||||||
@$(ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
|
@$(ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
|
||||||
'\n\t$$(QM)$(ECHO) " [FINISH] $$@"' \
|
'\n\t$$(QM)$(ECHO) " [FINISH] $$@"' \
|
||||||
'\n\t$$(Q)$$(CP) $$< $$@' \
|
'\n\t$$(Q)$$(CP) $$< $$@' \
|
||||||
|
'\n\t$$(Q)$$(PAD_$(1))' \
|
||||||
'\n\t$$(Q)$$(FINALISE_$(1))' \
|
'\n\t$$(Q)$$(FINALISE_$(1))' \
|
||||||
> $(2)
|
> $(2)
|
||||||
|
|
||||||
@@ -459,7 +794,20 @@ $(BIN)/deps/%.media.d : $(MAKEDEPS)
|
|||||||
MEDIA_DEPS = $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
|
MEDIA_DEPS = $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
|
||||||
mediadeps :
|
mediadeps :
|
||||||
@$(ECHO) $(MEDIA_DEPS)
|
@$(ECHO) $(MEDIA_DEPS)
|
||||||
|
ifdef NEED_DEPS
|
||||||
|
ifneq ($(MEDIA_DEPS),)
|
||||||
-include $(MEDIA_DEPS)
|
-include $(MEDIA_DEPS)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Wrap up binary blobs (for embedded images)
|
||||||
|
#
|
||||||
|
$(BIN)/%.o : payload/%.img
|
||||||
|
$(QM)echo " [WRAP] $@"
|
||||||
|
$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
|
||||||
|
--defsym obj_$*=0
|
||||||
|
|
||||||
|
BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
|
||||||
|
|
||||||
# The "allXXXs" targets for each suffix
|
# The "allXXXs" targets for each suffix
|
||||||
#
|
#
|
||||||
@@ -472,15 +820,23 @@ allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%
|
|||||||
$(BIN)/etherboot.% : $(BIN)/gpxe.%
|
$(BIN)/etherboot.% : $(BIN)/gpxe.%
|
||||||
ln -sf $(notdir $<) $@
|
ln -sf $(notdir $<) $@
|
||||||
|
|
||||||
# Wrap up binary blobs
|
endif # defined(BIN)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
#
|
#
|
||||||
$(BIN)/%.o : payload/%.img
|
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
|
||||||
$(QM)echo " [WRAP] $@"
|
# the automatic build system and varies by target; it includes the
|
||||||
$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
|
# "-p 0x1234,0x5678" string to set the PCI IDs.
|
||||||
--defsym obj_$*=0
|
#
|
||||||
|
FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
|
||||||
|
-i$(IDENT) -s 0 $@
|
||||||
|
|
||||||
BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
|
# Some ROMs require specific flags to be passed to makerom.pl
|
||||||
|
#
|
||||||
|
MAKEROM_FLAGS_3c503 = -3
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
# The compression utilities
|
# The compression utilities
|
||||||
#
|
#
|
||||||
$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
|
$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
|
||||||
@@ -494,6 +850,40 @@ $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
|
|||||||
$(Q)$(HOST_CC) -O2 -o $@ $<
|
$(Q)$(HOST_CC) -O2 -o $@ $<
|
||||||
CLEANUP += $(ZBIN)
|
CLEANUP += $(ZBIN)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# The EFI image converter
|
||||||
|
#
|
||||||
|
ELF2EFI_CFLAGS := -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
|
||||||
|
-idirafter include -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib \
|
||||||
|
-lbfd -liberty -lz
|
||||||
|
|
||||||
|
$(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
|
||||||
|
$(QM)$(ECHO) " [HOSTCC] $@"
|
||||||
|
$(Q)$(HOST_CC) $(ELF2EFI_CFLAGS) -DMDE_CPU_IA32 -O2 -o $@ $<
|
||||||
|
CLEANUP += $(ELF2EFI32)
|
||||||
|
|
||||||
|
$(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
|
||||||
|
$(QM)$(ECHO) " [HOSTCC] $@"
|
||||||
|
$(Q)$(HOST_CC) $(ELF2EFI_CFLAGS) -DMDE_CPU_X64 -O2 -o $@ $<
|
||||||
|
CLEANUP += $(ELF2EFI64)
|
||||||
|
|
||||||
|
$(EFIROM) : util/efirom.c $(MAKEDEPS)
|
||||||
|
$(QM)$(ECHO) " [HOSTCC] $@"
|
||||||
|
$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
|
||||||
|
CLEANUP += $(EFIROM)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# The ICC fixup utility
|
||||||
|
#
|
||||||
|
$(ICCFIX) : util/iccfix.c $(MAKEDEPS)
|
||||||
|
$(QM)$(ECHO) " [HOSTCC] $@"
|
||||||
|
$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
|
||||||
|
CLEANUP += $(ICCFIX)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
# Auto-incrementing build serial number. Append "bs" to your list of
|
# Auto-incrementing build serial number. Append "bs" to your list of
|
||||||
# build targets to get a serial number printed at the end of the
|
# build targets to get a serial number printed at the end of the
|
||||||
# build. Enable -DBUILD_SERIAL in order to see it when the code runs.
|
# build. Enable -DBUILD_SERIAL in order to see it when the code runs.
|
||||||
@@ -517,27 +907,30 @@ bs : $(BUILDSERIAL_NOW)
|
|||||||
@$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
|
@$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
|
||||||
@$(ECHO) "Build serial number is $(shell cat $<)"
|
@$(ECHO) "Build serial number is $(shell cat $<)"
|
||||||
|
|
||||||
# List of available architectures
|
###############################################################################
|
||||||
#
|
#
|
||||||
ARCHS = $(filter-out CVS,$(patsubst arch/%,%,$(wildcard arch/*)))
|
# Build the TAGS file(s) for emacs
|
||||||
archs :
|
|
||||||
@$(ECHO) $(ARCHS)
|
|
||||||
|
|
||||||
OTHER_ARCHS = $(filter-out $(ARCH),$(ARCHS))
|
|
||||||
otherarchs :
|
|
||||||
@$(ECHO) $(OTHER_ARCHS)
|
|
||||||
|
|
||||||
# Build the TAGS file for emacs
|
|
||||||
#
|
#
|
||||||
TAGS : TAGS.$(ARCH)
|
TAGS :
|
||||||
|
ctags -e -R -f $@ --exclude=bin
|
||||||
|
|
||||||
TAGS.$(ARCH) :
|
CLEANUP += TAGS
|
||||||
ctags -e -R -f $@ --exclude=bin \
|
|
||||||
$(foreach ARCH,$(OTHER_ARCHS),--exclude=arch/$(ARCH))
|
|
||||||
CLEANUP += TAGS*
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Force rebuild for any given target
|
||||||
|
#
|
||||||
|
%.rebuild :
|
||||||
|
rm -f $*
|
||||||
|
$(Q)$(MAKE) $*
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
# Symbol table checks
|
# Symbol table checks
|
||||||
#
|
#
|
||||||
|
|
||||||
|
ifdef BIN
|
||||||
|
|
||||||
SYMTAB = $(BIN)/symtab
|
SYMTAB = $(BIN)/symtab
|
||||||
$(SYMTAB) : $(BLIB)
|
$(SYMTAB) : $(BLIB)
|
||||||
$(OBJDUMP) -w -t $< > $@
|
$(OBJDUMP) -w -t $< > $@
|
||||||
@@ -547,29 +940,46 @@ CLEANUP += $(BIN)/symtab
|
|||||||
symcheck : $(SYMTAB)
|
symcheck : $(SYMTAB)
|
||||||
$(SYMCHECK) $<
|
$(SYMCHECK) $<
|
||||||
|
|
||||||
# Force rebuild for any given target
|
endif # defined(BIN)
|
||||||
#
|
|
||||||
$(BIN)/%.rebuild :
|
|
||||||
rm -f $(BIN)/$*
|
|
||||||
$(MAKE) $(MAKEFLAGS) $(BIN)/$*
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Build bochs symbol table
|
||||||
|
#
|
||||||
|
|
||||||
|
ifdef BIN
|
||||||
|
|
||||||
|
$(BIN)/%.bxs : $(BIN)/%.tmp
|
||||||
|
$(NM) $< | cut -d" " -f1,3 > $@
|
||||||
|
|
||||||
|
endif # defined(BIN)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
# Documentation
|
# Documentation
|
||||||
#
|
#
|
||||||
|
|
||||||
|
ifdef BIN
|
||||||
|
|
||||||
$(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
|
$(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
|
||||||
$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
|
$(Q)$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
|
||||||
|
-e 's{\@INCDIRS\@}{$(filter-out .,$(INCDIRS))}; ' \
|
||||||
-e 's{\@BIN\@}{$(BIN)}; ' \
|
-e 's{\@BIN\@}{$(BIN)}; ' \
|
||||||
-e 's{\@ARCH\@}{$(ARCH)}; ' \
|
-e 's{\@ARCH\@}{$(ARCH)}; ' \
|
||||||
$< > $@
|
$< > $@
|
||||||
|
|
||||||
$(BIN)/doc : $(BIN)/doxygen.cfg
|
$(BIN)/doc : $(BIN)/doxygen.cfg
|
||||||
$(DOXYGEN) $<
|
$(Q)$(DOXYGEN) $<
|
||||||
|
|
||||||
.PHONY : $(BIN)/doc
|
.PHONY : $(BIN)/doc
|
||||||
|
|
||||||
VERYCLEANUP += $(BIN)/doc
|
|
||||||
|
|
||||||
doc : $(BIN)/doc
|
doc : $(BIN)/doc
|
||||||
|
|
||||||
|
doc-clean :
|
||||||
|
$(Q)$(RM) -r $(BIN)/doc
|
||||||
|
|
||||||
|
VERYCLEANUP += $(BIN)/doc
|
||||||
|
|
||||||
docview :
|
docview :
|
||||||
@[ -f $(BIN)/doc/html/index.html ] || $(MAKE) $(BIN)/doc
|
@[ -f $(BIN)/doc/html/index.html ] || $(MAKE) $(BIN)/doc
|
||||||
@if [ -n "$$BROWSER" ] ; then \
|
@if [ -n "$$BROWSER" ] ; then \
|
||||||
@@ -578,6 +988,10 @@ docview :
|
|||||||
$(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
|
$(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
endif # defined(BIN)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
# Clean-up
|
# Clean-up
|
||||||
#
|
#
|
||||||
clean :
|
clean :
|
||||||
@@ -585,19 +999,3 @@ clean :
|
|||||||
|
|
||||||
veryclean : clean
|
veryclean : clean
|
||||||
$(RM) -r $(VERYCLEANUP)
|
$(RM) -r $(VERYCLEANUP)
|
||||||
|
|
||||||
# Make clean tarballs for release
|
|
||||||
|
|
||||||
tarball : ../VERSION
|
|
||||||
($(ECHO) -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
|
|
||||||
$(RM) -r /tmp/$(USER)/gpxe-$(VERSION)
|
|
||||||
mkdir -p /tmp/$(USER)/gpxe-$(VERSION)
|
|
||||||
cp -rP .. /tmp/$(USER)/gpxe-$(VERSION)
|
|
||||||
( cd /tmp/$(USER)/gpxe-$(VERSION)/src ; $(MAKE) veryclean ; $(RM) -r bin/deps )
|
|
||||||
( cd /tmp/$(USER); tar cf /tmp/$(USER)/gpxe-$(VERSION).tar --exclude ".git*" --exclude "#*" \
|
|
||||||
--exclude "*~" gpxe-$(VERSION) )
|
|
||||||
bzip2 -9 < /tmp/$(USER)/gpxe-$(VERSION).tar > /tmp/$(USER)/gpxe-$(VERSION).tar.bz2
|
|
||||||
gzip -9 < /tmp/$(USER)/gpxe-$(VERSION).tar > /tmp/$(USER)/gpxe-$(VERSION).tar.gz
|
|
||||||
$(RM) -r /tmp/$(USER)/gpxe-$(VERSION)
|
|
||||||
$(RM) /tmp/$(USER)/gpxe-$(VERSION).tar
|
|
||||||
( cd /tmp/$(USER) ; tar -zxf /tmp/$(USER)/gpxe-$(VERSION).tar.gz )
|
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
This file documents the driver changes needed to support use as part
|
|
||||||
of a PXE stack.
|
|
||||||
|
|
||||||
PROPER WAY
|
|
||||||
==========
|
|
||||||
|
|
||||||
1. The probe() routine.
|
|
||||||
|
|
||||||
There are three additional fields that need to be filled in the nic
|
|
||||||
structure: ioaddr, irqno and irq.
|
|
||||||
|
|
||||||
ioaddr is the base I/O address and seems to be for information only;
|
|
||||||
no use will be made of this value other than displaying it on the
|
|
||||||
screen.
|
|
||||||
|
|
||||||
irqno must be the IRQ number for the NIC. For PCI NICs this can
|
|
||||||
simply be copied from pci->irq.
|
|
||||||
|
|
||||||
irq is a function pointer, like poll and transmit. It must point to
|
|
||||||
the driver's irq() function.
|
|
||||||
|
|
||||||
2. The poll() routine.
|
|
||||||
|
|
||||||
This must take an additional parameter: "int retrieve". Calling
|
|
||||||
poll() with retrieve!=0 should function exactly as before. Calling
|
|
||||||
poll() with retrieve==0 indicates that poll() should check for the
|
|
||||||
presence of a packet to read, but must *not* read the packet. The
|
|
||||||
packet will be read by a subsequent call to poll() with retrieve!=0.
|
|
||||||
|
|
||||||
The easiest way to implement this is to insert the line
|
|
||||||
if ( ! retrieve ) return 1;
|
|
||||||
between the "is there a packet ready" and the "fetch packet" parts of
|
|
||||||
the existing poll() routine.
|
|
||||||
|
|
||||||
Care must be taken that a call to poll() with retrieve==0 does not
|
|
||||||
clear the NIC's "packet ready" status indicator, otherwise the
|
|
||||||
subsequent call to poll() with retrieve!=0 will fail because it will
|
|
||||||
think that there is no packet to read.
|
|
||||||
|
|
||||||
poll() should also acknowledge and clear the NIC's "packet received"
|
|
||||||
interrupt. It does not need to worry about enabling/disabling
|
|
||||||
interrupts; this is taken care of by calls to the driver's irq()
|
|
||||||
routine.
|
|
||||||
|
|
||||||
Etherboot will forcibly regenerate an interrupt if a packet remains
|
|
||||||
pending after all interrupts have been acknowledged. You can
|
|
||||||
therefore get away with having poll() just acknolwedge and clear all
|
|
||||||
NIC interrupts, without particularly worrying about exactly when this
|
|
||||||
should be done.
|
|
||||||
|
|
||||||
3. The irq() routine.
|
|
||||||
|
|
||||||
This is a new routine, with prototype
|
|
||||||
void DRIVER_irq ( struct nic *nic, irq_action_t action );
|
|
||||||
"action" takes one of three possible values: ENABLE, DISABLE or FORCE.
|
|
||||||
ENABLE and DISABLE mean to enable/disable the NIC's "packet received"
|
|
||||||
interrupt. FORCE means that the NIC should be forced to generate a
|
|
||||||
fake "packet received" interrupt.
|
|
||||||
|
|
||||||
If you are unable to implement FORCE, your NIC will not work when
|
|
||||||
being driven via the UNDI interface under heavy network traffic
|
|
||||||
conditions. Since Etherboot's UNDI driver (make bin/undi.zpxe) is the
|
|
||||||
only program known to use this interface, it probably doesn't really
|
|
||||||
matter.
|
|
||||||
|
|
||||||
|
|
||||||
QUICK AND DIRTY WAY
|
|
||||||
===================
|
|
||||||
|
|
||||||
It is possible to use the system timer interrupt (IRQ 0) rather than a
|
|
||||||
genuine NIC interrupt. Since there is a constant stream of timer
|
|
||||||
interrupts, the net upshot is a whole load of spurious "NIC"
|
|
||||||
interrupts that have no effect other than to cause unnecessary PXE API
|
|
||||||
calls. It's inefficient but it works.
|
|
||||||
|
|
||||||
To achieve this, simply set nic->irqno=0 in probe() and point nic->irq
|
|
||||||
to a dummy routine that does nothing. Add the line
|
|
||||||
if ( ! retrieve ) return 1;
|
|
||||||
at the beginning of poll(), to prevent the packet being read (and
|
|
||||||
discarded) when poll() is called with retrieve==0;
|
|
||||||
|
|
||||||
|
|
||||||
UNCONVERTED DRIVERS
|
|
||||||
===================
|
|
||||||
|
|
||||||
Drivers that have not yet been converted should continue to function
|
|
||||||
when not used as part of a PXE stack, although there will be a
|
|
||||||
harmless compile-time warning about assignment from an incompatible
|
|
||||||
pointer type in the probe() function, since the prototype for the
|
|
||||||
poll() function is missing the "int retrieve" parameter.
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# IMPORTANT!
|
|
||||||
#
|
|
||||||
# The use of this file to set options that affect only single object
|
|
||||||
# files is deprecated, because changing anything in this file results
|
|
||||||
# in a complete rebuild, which is slow. All options are gradually
|
|
||||||
# being migrated to config.h, which does not suffer from this problem.
|
|
||||||
#
|
|
||||||
# Only options that affect the entire build (e.g. overriding the $(CC)
|
|
||||||
# Makefile variable) should be placed in here.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
# Config for i386 Etherboot
|
|
||||||
#
|
|
||||||
# Do not delete the tag OptionDescription and /OptionDescription
|
|
||||||
# It is used to automatically generate the documentation.
|
|
||||||
#
|
|
||||||
# @OptionDescrition@
|
|
||||||
#
|
|
||||||
# BIOS interface options:
|
|
||||||
#
|
|
||||||
# -DPCBIOS
|
|
||||||
# Compile in support for the normal pcbios
|
|
||||||
# -DLINUXBIOS
|
|
||||||
# Compile in support for LinuxBIOS
|
|
||||||
# -DBBS_BUT_NOT_PNP_COMPLIANT
|
|
||||||
# Some BIOSes claim to be PNP but they don't conform
|
|
||||||
# to the BBS spec which specifies that ES:DI must
|
|
||||||
# point to the string $PnP on entry. This option
|
|
||||||
# works around those. This option must be added to
|
|
||||||
# LCONFIG.
|
|
||||||
# -DNO_DELAYED_INT
|
|
||||||
# Take control as soon as BIOS detects the ROM.
|
|
||||||
# Normally hooks onto INT18H or INT19H. Use only if you
|
|
||||||
# have a very non-conformant BIOS as it bypasses
|
|
||||||
# BIOS initialisation of devices. This only works for
|
|
||||||
# legacy ROMs, i.e. PCI_PNP_HEADER not defined.
|
|
||||||
# This option was formerly called NOINT19H.
|
|
||||||
# -DBOOT_INT18H
|
|
||||||
# Etherboot normally hooks onto INT19H for legacy ROMs.
|
|
||||||
# You can choose to hook onto INT18H (BASIC interpreter
|
|
||||||
# entry point) instead. This entry point is used when
|
|
||||||
# all boot devices have been exhausted. This option must
|
|
||||||
# be added to LCONFIG.
|
|
||||||
# -DCONFIG_PCI_DIRECT
|
|
||||||
# Define this for PCI BIOSes that do not implement
|
|
||||||
# BIOS32 or not correctly. Normally not needed.
|
|
||||||
# Only works for BIOSes of a certain era.
|
|
||||||
# -DCONFIG_TSC_CURRTICKS
|
|
||||||
# Uses the processor time stamp counter instead of reading
|
|
||||||
# the BIOS time counter. This allows Etherboot to work
|
|
||||||
# even without a BIOS. This only works on late model
|
|
||||||
# 486s and above.
|
|
||||||
# -DCONFIG_NO_TIMER2
|
|
||||||
# Some systems do not have timer2 implemented.
|
|
||||||
# If you have a RTC this will allow you to roughly calibrate
|
|
||||||
# it using outb instructions.
|
|
||||||
#
|
|
||||||
# Extended cpu options
|
|
||||||
|
|
||||||
# -DCONFIG_X86_64
|
|
||||||
# Compile in support for booting x86_64 64bit binaries.
|
|
||||||
#
|
|
||||||
# PXE loader options:
|
|
||||||
#
|
|
||||||
# -DPXELOADER_KEEP_ALL
|
|
||||||
# Prevent PXE loader (prefix) from unloading the
|
|
||||||
# PXE stack. You will want to use this if, for
|
|
||||||
# example, you are booting via PXE-on-floppy.
|
|
||||||
# You may want to use it under certain
|
|
||||||
# circumstances when using the Etherboot UNDI
|
|
||||||
# driver; these are complex and best practice is
|
|
||||||
# not yet established.
|
|
||||||
#
|
|
||||||
# Obscure options you probably don't need to touch:
|
|
||||||
#
|
|
||||||
# -DIGNORE_E820_MAP
|
|
||||||
# Ignore the memory map returned by the E820 BIOS
|
|
||||||
# call. May be necessary on some buggy BIOSes.
|
|
||||||
# -DT503_AUI
|
|
||||||
# Use AUI by default on 3c503 cards.
|
|
||||||
# -DFLATTEN_REAL_MODE
|
|
||||||
# Use 4GB segment limits when calling out to or
|
|
||||||
# returning to real-mode code. This is necessary to
|
|
||||||
# work around some buggy code (e.g. OpenBSD's pxeboot)
|
|
||||||
# that uses flat real-mode without being sufficiently
|
|
||||||
# paranoid about the volatility of its segment limits.
|
|
||||||
|
|
||||||
#
|
|
||||||
# @/OptionDescription@
|
|
||||||
|
|
||||||
# BIOS select don't change unless you know what you are doing
|
|
||||||
# CFLAGS+= -DPCBIOS
|
|
||||||
|
|
||||||
# Compile in k8/hammer support
|
|
||||||
# CFLAGS+= -DCONFIG_X86_64
|
|
||||||
|
|
||||||
# Options to make a version of Etherboot that will work under linuxBIOS.
|
|
||||||
# CFLAGS+= -DLINUXBIOS -DCONFIG_TSC_CURRTICKS -DCONSOLE_SERIAL -DCOMCONSOLE=0x3f8 -DCOMPRESERVE -DCONFIG_PCI_DIRECT -DELF_IMAGE
|
|
||||||
|
|
||||||
# These options affect the loader that is prepended to the Etherboot image
|
|
||||||
# LCONFIG+= -DBBS_BUT_NOT_PNP_COMPLIANT
|
|
||||||
# LCONFIG+= -DBOOT_INT18H
|
|
||||||
|
|
||||||
# Produce code that will work with OpenBSD's pxeboot
|
|
||||||
# CFLAGS+= -DFLATTEN_REAL_MODE
|
|
||||||
|
|
||||||
CFLAGS+= -fstrength-reduce -fomit-frame-pointer -march=i386
|
|
||||||
# Squeeze the code in as little space as possible.
|
|
||||||
# gcc3 needs a different syntax to gcc2 if you want to avoid spurious warnings.
|
|
||||||
GCC_VERSION = $(subst ., ,$(shell $(CC) -dumpversion))
|
|
||||||
GCC_MAJORVERSION = $(firstword $(GCC_VERSION))
|
|
||||||
ifeq ($(GCC_MAJORVERSION),2)
|
|
||||||
CFLAGS+= -malign-jumps=1 -malign-loops=1 -malign-functions=1
|
|
||||||
else
|
|
||||||
CFLAGS+= -falign-jumps=1 -falign-loops=1 -falign-functions=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
# this is almost always a win. the kernel uses it, too.
|
|
||||||
CFLAGS+= -mpreferred-stack-boundary=2
|
|
||||||
|
|
||||||
# use regparm for all functions - C functions called from assembly (or
|
|
||||||
# vice versa) need __cdecl now
|
|
||||||
CFLAGS+= -mregparm=3
|
|
||||||
|
|
||||||
# use -mrtd (same __cdecl requirements as above)
|
|
||||||
CFLAGS+= -mrtd
|
|
||||||
|
|
||||||
# this is the logical complement to -mregparm=3.
|
|
||||||
# it doesn't currently buy us anything, but if anything ever tries
|
|
||||||
# to return small structures, let's be prepared
|
|
||||||
CFLAGS+= -freg-struct-return
|
|
||||||
|
|
||||||
LDFLAGS+= -N --no-check-sections
|
|
||||||
|
|
||||||
ifeq "$(shell uname -s)" "FreeBSD"
|
|
||||||
CFLAGS+= -DIMAGE_FREEBSD -DELF_IMAGE -DAOUT_IMAGE
|
|
||||||
endif
|
|
||||||
|
|
||||||
# An alternate location for isolinux.bin can be set here
|
|
||||||
# ISOLINUX_BIN=/path/to/isolinux.bin
|
|
||||||
+80
-70
@@ -1,3 +1,72 @@
|
|||||||
|
# Force i386-only instructions
|
||||||
|
#
|
||||||
|
CFLAGS += -march=i386
|
||||||
|
|
||||||
|
# Code size reduction.
|
||||||
|
#
|
||||||
|
CFLAGS += -fomit-frame-pointer
|
||||||
|
|
||||||
|
# Code size reduction.
|
||||||
|
#
|
||||||
|
ifeq ($(CCTYPE),gcc)
|
||||||
|
CFLAGS += -fstrength-reduce
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Code size reduction. gcc3 needs a different syntax to gcc2 if you
|
||||||
|
# want to avoid spurious warnings.
|
||||||
|
#
|
||||||
|
ifeq ($(CCTYPE),gcc)
|
||||||
|
GCC_VERSION := $(subst ., ,$(shell $(CC) -dumpversion))
|
||||||
|
GCC_MAJOR := $(firstword $(GCC_VERSION))
|
||||||
|
ifeq ($(GCC_MAJOR),2)
|
||||||
|
CFLAGS += -malign-jumps=1 -malign-loops=1 -malign-functions=1
|
||||||
|
else
|
||||||
|
CFLAGS += -falign-jumps=1 -falign-loops=1 -falign-functions=1
|
||||||
|
endif # gcc2
|
||||||
|
endif # gcc
|
||||||
|
|
||||||
|
# Code size reduction. This is almost always a win. The kernel uses
|
||||||
|
# it, too.
|
||||||
|
#
|
||||||
|
ifeq ($(CCTYPE),gcc)
|
||||||
|
CFLAGS += -mpreferred-stack-boundary=2
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Code size reduction. Use regparm for all functions - C functions
|
||||||
|
# called from assembly (or vice versa) need __asmcall now
|
||||||
|
#
|
||||||
|
CFLAGS += -mregparm=3
|
||||||
|
|
||||||
|
# Code size reduction. Use -mrtd (same __asmcall requirements as above)
|
||||||
|
ifeq ($(CCTYPE),gcc)
|
||||||
|
CFLAGS += -mrtd
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Code size reduction. This is the logical complement to -mregparm=3.
|
||||||
|
# It doesn't currently buy us anything, but if anything ever tries to
|
||||||
|
# return small structures, let's be prepared
|
||||||
|
#
|
||||||
|
CFLAGS += -freg-struct-return
|
||||||
|
|
||||||
|
# Force 32-bit code even on an x86-64 machine
|
||||||
|
#
|
||||||
|
CFLAGS += -m32
|
||||||
|
ASFLAGS += --32
|
||||||
|
ifeq ($(HOST_OS),FreeBSD)
|
||||||
|
LDFLAGS += -m elf_i386_fbsd
|
||||||
|
else
|
||||||
|
LDFLAGS += -m elf_i386
|
||||||
|
endif
|
||||||
|
|
||||||
|
# EFI requires -fshort-wchar, and nothing else currently uses wchar_t
|
||||||
|
#
|
||||||
|
CFLAGS += -fshort-wchar
|
||||||
|
|
||||||
|
# We need to undefine the default macro "i386" when compiling .S
|
||||||
|
# files, otherwise ".arch i386" translates to ".arch 1"...
|
||||||
|
#
|
||||||
|
CFLAGS += -Ui386
|
||||||
|
|
||||||
# Locations of utilities
|
# Locations of utilities
|
||||||
#
|
#
|
||||||
ISOLINUX_BIN = /usr/lib/syslinux/isolinux.bin
|
ISOLINUX_BIN = /usr/lib/syslinux/isolinux.bin
|
||||||
@@ -12,6 +81,7 @@ SRCDIRS += arch/i386/drivers/net
|
|||||||
SRCDIRS += arch/i386/interface/pcbios
|
SRCDIRS += arch/i386/interface/pcbios
|
||||||
SRCDIRS += arch/i386/interface/pxe
|
SRCDIRS += arch/i386/interface/pxe
|
||||||
SRCDIRS += arch/i386/interface/syslinux
|
SRCDIRS += arch/i386/interface/syslinux
|
||||||
|
SRCDIRS += arch/i386/hci/commands
|
||||||
|
|
||||||
# The various xxx_loader.c files are #included into core/loader.c and
|
# The various xxx_loader.c files are #included into core/loader.c and
|
||||||
# should not be compiled directly.
|
# should not be compiled directly.
|
||||||
@@ -20,87 +90,27 @@ NON_AUTO_SRCS += arch/i386/core/aout_loader.c
|
|||||||
NON_AUTO_SRCS += arch/i386/core/freebsd_loader.c
|
NON_AUTO_SRCS += arch/i386/core/freebsd_loader.c
|
||||||
NON_AUTO_SRCS += arch/i386/core/wince_loader.c
|
NON_AUTO_SRCS += arch/i386/core/wince_loader.c
|
||||||
|
|
||||||
# unnrv2b.S is used to generate a 16-bit as well as a 32-bit object.
|
# Include common x86 Makefile
|
||||||
#
|
#
|
||||||
OBJS_unnrv2b = unnrv2b unnrv2b16
|
MAKEDEPS += arch/x86/Makefile
|
||||||
CFLAGS_unnrv2b16 = -DCODE16
|
include arch/x86/Makefile
|
||||||
|
|
||||||
# We need to undefine the default macro "i386" when compiling .S
|
# Include platform-specific Makefile
|
||||||
# files, otherwise ".arch i386" translates to ".arch 1"...
|
|
||||||
#
|
#
|
||||||
CFLAGS_S += -Ui386
|
MAKEDEPS += arch/i386/Makefile.$(PLATFORM)
|
||||||
|
include arch/i386/Makefile.$(PLATFORM)
|
||||||
# The i386 linker script
|
|
||||||
#
|
|
||||||
LDSCRIPT = arch/i386/scripts/i386.lds
|
|
||||||
|
|
||||||
# Media types.
|
|
||||||
#
|
|
||||||
MEDIA += rom
|
|
||||||
MEDIA += pxe
|
|
||||||
MEDIA += kpxe
|
|
||||||
MEDIA += elf
|
|
||||||
MEDIA += elfd
|
|
||||||
MEDIA += lmelf
|
|
||||||
MEDIA += lmelfd
|
|
||||||
MEDIA += lkrn
|
|
||||||
MEDIA += bImage
|
|
||||||
MEDIA += dsk
|
|
||||||
MEDIA += nbi
|
|
||||||
MEDIA += hd
|
|
||||||
MEDIA += raw
|
|
||||||
MEDIA += com
|
|
||||||
MEDIA += exe
|
|
||||||
|
|
||||||
# Special target for building Master Boot Record binary
|
|
||||||
$(BIN)/mbr.bin : $(BIN)/mbr.o
|
|
||||||
$(OBJCOPY) -O binary $< $@
|
|
||||||
|
|
||||||
# Some suffixes (e.g. %.fd0) are generated directly from other
|
# Some suffixes (e.g. %.fd0) are generated directly from other
|
||||||
# finished files (e.g. %.dsk), rather than having their own prefix.
|
# finished files (e.g. %.dsk), rather than having their own prefix.
|
||||||
|
|
||||||
# rule to write disk images to /dev/fd0
|
# rule to write disk images to /dev/fd0
|
||||||
NON_AUTO_MEDIA += fd0
|
NON_AUTO_MEDIA += fd0
|
||||||
%fd0 : %dsk
|
%fd0 : %dsk
|
||||||
dd if=$< bs=512 conv=sync of=/dev/fd0
|
$(QM)$(ECHO) " [DD] $@"
|
||||||
sync
|
$(Q)dd if=$< bs=512 conv=sync of=/dev/fd0
|
||||||
|
$(Q)sync
|
||||||
# rule to create padded disk images
|
|
||||||
NON_AUTO_MEDIA += pdsk
|
|
||||||
%pdsk : %dsk
|
|
||||||
cp $< $@
|
|
||||||
$(PERL) ./util/dskpad.pl $@
|
|
||||||
|
|
||||||
# rule to make a non-emulation ISO boot image
|
|
||||||
NON_AUTO_MEDIA += iso
|
|
||||||
%iso: %lkrn util/geniso
|
|
||||||
ISOLINUX_BIN=$(ISOLINUX_BIN) bash util/geniso $@ $<
|
|
||||||
|
|
||||||
# rule to make a floppy emulation ISO boot image
|
|
||||||
NON_AUTO_MEDIA += liso
|
|
||||||
%liso: %lkrn util/genliso
|
|
||||||
bash util/genliso $@ $<
|
|
||||||
|
|
||||||
# rule to make a USB disk image
|
|
||||||
$(BIN)/usbdisk.bin : $(BIN)/usbdisk.o
|
|
||||||
$(OBJCOPY) -O binary $< $@
|
|
||||||
|
|
||||||
NON_AUTO_MEDIA += usb
|
|
||||||
%usb: $(BIN)/usbdisk.bin %hd
|
|
||||||
cat $^ > $@
|
|
||||||
|
|
||||||
# Add NON_AUTO_MEDIA to the media list, so that they show up in the
|
# Add NON_AUTO_MEDIA to the media list, so that they show up in the
|
||||||
# output of "make"
|
# output of "make"
|
||||||
#
|
#
|
||||||
MEDIA += $(NON_AUTO_MEDIA)
|
MEDIA += $(NON_AUTO_MEDIA)
|
||||||
|
|
||||||
# Shortcut to allow typing just
|
|
||||||
# make bin-kir/%
|
|
||||||
# rather than
|
|
||||||
# make -f arch/i386/kir-Makefile bin-kir/%
|
|
||||||
# for building a KEEP_IT_REAL flavour.
|
|
||||||
#
|
|
||||||
$(BIN)-kir/% : kir-target
|
|
||||||
$(MAKE) -f arch/i386/kir-Makefile $(MAKECMDGOALS)
|
|
||||||
|
|
||||||
.PHONY : kir-target
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||||
|
|
||||||
|
# Specify EFI image builder
|
||||||
|
#
|
||||||
|
ELF2EFI = $(ELF2EFI32)
|
||||||
|
|
||||||
|
# Include generic EFI Makefile
|
||||||
|
#
|
||||||
|
MAKEDEPS += arch/x86/Makefile.efi
|
||||||
|
include arch/x86/Makefile.efi
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||||
|
|
||||||
|
# The i386 linker script
|
||||||
|
#
|
||||||
|
LDSCRIPT = arch/i386/scripts/i386.lds
|
||||||
|
|
||||||
|
# Stop ld from complaining about our customised linker script
|
||||||
|
#
|
||||||
|
LDFLAGS += -N --no-check-sections
|
||||||
|
|
||||||
|
# Media types.
|
||||||
|
#
|
||||||
|
MEDIA += rom
|
||||||
|
MEDIA += pxe
|
||||||
|
MEDIA += kpxe
|
||||||
|
MEDIA += kkpxe
|
||||||
|
MEDIA += elf
|
||||||
|
MEDIA += elfd
|
||||||
|
MEDIA += lmelf
|
||||||
|
MEDIA += lmelfd
|
||||||
|
MEDIA += lkrn
|
||||||
|
MEDIA += bImage
|
||||||
|
MEDIA += dsk
|
||||||
|
MEDIA += nbi
|
||||||
|
MEDIA += hd
|
||||||
|
MEDIA += raw
|
||||||
|
MEDIA += com
|
||||||
|
MEDIA += exe
|
||||||
|
|
||||||
|
# Padding rules
|
||||||
|
#
|
||||||
|
PAD_rom = $(PADIMG) --blksize=512 --byte=0xff $@
|
||||||
|
PAD_dsk = $(PADIMG) --blksize=512 $@
|
||||||
|
PAD_hd = $(PADIMG) --blksize=512 $@
|
||||||
|
|
||||||
|
# rule to make a non-emulation ISO boot image
|
||||||
|
NON_AUTO_MEDIA += iso
|
||||||
|
%iso: %lkrn util/geniso
|
||||||
|
$(QM)$(ECHO) " [GENISO] $@"
|
||||||
|
$(Q)ISOLINUX_BIN=$(ISOLINUX_BIN) bash util/geniso $@ $<
|
||||||
|
|
||||||
|
# rule to make a floppy emulation ISO boot image
|
||||||
|
NON_AUTO_MEDIA += liso
|
||||||
|
%liso: %lkrn util/genliso
|
||||||
|
$(QM)$(ECHO) " [GENLISO] $@"
|
||||||
|
$(Q)bash util/genliso $@ $<
|
||||||
|
|
||||||
|
# rule to make a syslinux floppy image (mountable, bootable)
|
||||||
|
NON_AUTO_MEDIA += sdsk
|
||||||
|
%sdsk: %lkrn util/gensdsk
|
||||||
|
$(QM)$(ECHO) " [GENSDSK] $@"
|
||||||
|
$(Q)bash util/gensdsk $@ $<
|
||||||
|
|
||||||
|
# Special target for building Master Boot Record binary
|
||||||
|
$(BIN)/mbr.bin : $(BIN)/mbr.o
|
||||||
|
$(QM)$(ECHO) " [OBJCOPY] $@"
|
||||||
|
$(Q)$(OBJCOPY) -O binary $< $@
|
||||||
|
|
||||||
|
# rule to make a USB disk image
|
||||||
|
$(BIN)/usbdisk.bin : $(BIN)/usbdisk.o
|
||||||
|
$(QM)$(ECHO) " [OBJCOPY] $@"
|
||||||
|
$(Q)$(OBJCOPY) -O binary $< $@
|
||||||
|
|
||||||
|
NON_AUTO_MEDIA += usb
|
||||||
|
%usb: $(BIN)/usbdisk.bin %hd
|
||||||
|
$(QM)$(ECHO) " [FINISH] $@"
|
||||||
|
$(Q)cat $^ > $@
|
||||||
|
|
||||||
|
# Padded floppy image (e.g. for iLO)
|
||||||
|
NON_AUTO_MEDIA += pdsk
|
||||||
|
%pdsk : %dsk
|
||||||
|
$(Q)cp $< $@
|
||||||
|
$(Q)$(PADIMG) --blksize=1474560 $@
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
|
|
||||||
void __cdecl _dump_regs ( struct i386_all_regs *ix86 ) {
|
void __asmcall _dump_regs ( struct i386_all_regs *ix86 ) {
|
||||||
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
TEXT16_CODE ( ".globl dump_regs\n\t"
|
TEXT16_CODE ( ".globl dump_regs\n\t"
|
||||||
@@ -12,8 +12,8 @@ void __cdecl _dump_regs ( struct i386_all_regs *ix86 ) {
|
|||||||
"addr32 leal 4(%%esp), %%esp\n\t"
|
"addr32 leal 4(%%esp), %%esp\n\t"
|
||||||
"ret\n\t" ) : : );
|
"ret\n\t" ) : : );
|
||||||
|
|
||||||
printf ( "EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
|
printf ( "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
|
||||||
"ESI=%08lx EDI=%08lx EBP=%08lx ESP=%08lx\n"
|
"ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n"
|
||||||
"CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x\n",
|
"CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x\n",
|
||||||
ix86->regs.eax, ix86->regs.ebx, ix86->regs.ecx,
|
ix86->regs.eax, ix86->regs.ebx, ix86->regs.ecx,
|
||||||
ix86->regs.edx, ix86->regs.esi, ix86->regs.edi,
|
ix86->regs.edx, ix86->regs.esi, ix86->regs.edi,
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
|
|
||||||
OUTPUT_ARCH(i386)
|
|
||||||
|
|
||||||
ENTRY(_prefix_start)
|
|
||||||
SECTIONS {
|
|
||||||
/* Prefix */
|
|
||||||
.prefix : {
|
|
||||||
_verbatim_start = . ;
|
|
||||||
_prefix_start = . ;
|
|
||||||
*(.prefix)
|
|
||||||
. = ALIGN(16);
|
|
||||||
_prefix_end = . ;
|
|
||||||
} = 0x9090
|
|
||||||
_prefix_size = _prefix_end - _prefix_start;
|
|
||||||
|
|
||||||
.text.nocompress : {
|
|
||||||
*(.prefix.udata)
|
|
||||||
} = 0x9090
|
|
||||||
|
|
||||||
decompress_to = . ;
|
|
||||||
.prefix.zdata : {
|
|
||||||
_compressed = . ;
|
|
||||||
*(.prefix.zdata)
|
|
||||||
_compressed_end = . ;
|
|
||||||
}
|
|
||||||
_compressed_size = _compressed_end - _compressed;
|
|
||||||
|
|
||||||
. = ALIGN(16);
|
|
||||||
_verbatim_end = . ;
|
|
||||||
|
|
||||||
|
|
||||||
/* Size of the core of etherboot in memory */
|
|
||||||
_base_size = _end - _text;
|
|
||||||
|
|
||||||
/* _prefix_size is the length of the non-core etherboot prefix */
|
|
||||||
_prefix_size = _prefix_end - _prefix_start;
|
|
||||||
|
|
||||||
/* _verbatim_size is the actual amount that has to be copied to base memory */
|
|
||||||
_verbatim_size = _verbatim_end - _verbatim_start;
|
|
||||||
|
|
||||||
/* _image_size is the amount of base memory needed to run */
|
|
||||||
_image_size = _base_size + _prefix_size;
|
|
||||||
|
|
||||||
/* Standard sizes rounded up to paragraphs */
|
|
||||||
_prefix_size_pgh = (_prefix_size + 15) / 16;
|
|
||||||
_verbatim_size_pgh = (_verbatim_size + 15) / 16;
|
|
||||||
_image_size_pgh = (_image_size + 15) / 16 ;
|
|
||||||
|
|
||||||
/* Standard sizes in sectors */
|
|
||||||
_prefix_size_sct = (_prefix_size + 511) / 512;
|
|
||||||
_verbatim_size_sct = (_verbatim_size + 511) / 512;
|
|
||||||
_image_size_sct = (_image_size + 511) / 512;
|
|
||||||
|
|
||||||
/* Symbol offsets and sizes for the exe prefix */
|
|
||||||
_exe_hdr_size = 32;
|
|
||||||
_exe_size = _verbatim_size; /* Should this be - 32 to exclude the header? */
|
|
||||||
_exe_size_tail = (_exe_size) % 512;
|
|
||||||
_exe_size_pages = ((_exe_size) + 511) / 512;
|
|
||||||
_exe_bss_size = ((_image_size - _verbatim_size) + 15) / 16;
|
|
||||||
_exe_ss_offset = (_stack_offset + _prefix_size - _exe_hdr_size + 15) / 16 ;
|
|
||||||
|
|
||||||
/* This is where we copy the compressed image before decompression.
|
|
||||||
* Prepare to decompress in place. The end mark is about 8.25 bytes long,
|
|
||||||
* and the worst case symbol is about 16.5 bytes long. Therefore
|
|
||||||
* We need to reserve at least 25 bytes of slack here.
|
|
||||||
* Currently I reserve 2048 bytes of just slack to be safe :)
|
|
||||||
* 2048 bytes easily falls within the BSS (the defualt stack is 4096 bytes)
|
|
||||||
* so we really are decompressing in place.
|
|
||||||
*
|
|
||||||
* Hmm. I missed a trick. In the very worst case (no compression)
|
|
||||||
* the encoded data is 9/8 the size as it started out so to be completely
|
|
||||||
* safe I need to be 1/8 of the uncompressed code size past the end.
|
|
||||||
* This will still fit compfortably into our bss in any conceivable scenario.
|
|
||||||
*/
|
|
||||||
_compressed_copy = _edata + _prefix_size - _compressed_size +
|
|
||||||
/* The amount to overflow _edata */
|
|
||||||
MAX( ((_edata - _text + 7) / 8) , 2016 ) + 32;
|
|
||||||
_assert = ASSERT( ( _compressed_copy - _prefix_size ) < _ebss , "Cannot decompress in place" ) ;
|
|
||||||
|
|
||||||
decompress = DEFINED(decompress) ? decompress : 0;
|
|
||||||
/DISCARD/ : {
|
|
||||||
*(.comment)
|
|
||||||
*(.note)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Symbols used by the prefixes whose addresses are inconvinient
|
|
||||||
* to compute, at runtime in the code.
|
|
||||||
*/
|
|
||||||
image_basemem_size = DEFINED(image_basemem_size)? image_basemem_size : 65536;
|
|
||||||
image_basemem = DEFINED(image_basemem)? image_basemem : 65536;
|
|
||||||
_prefix_real_to_prot = _real_to_prot + _prefix_size ;
|
|
||||||
_prefix_prot_to_real = _prot_to_real + _prefix_size ;
|
|
||||||
_prefix_image_basemem_size = image_basemem_size + _prefix_size ;
|
|
||||||
_prefix_image_basemem = image_basemem + _prefix_size ;
|
|
||||||
_prefix_rm_in_call = _rm_in_call + _prefix_size ;
|
|
||||||
_prefix_in_call = _in_call + _prefix_size ;
|
|
||||||
_prefix_rom = rom + _prefix_size ;
|
|
||||||
_prefix_rm_etherboot_location = rm_etherboot_location + _prefix_size ;
|
|
||||||
_prefix_stack_end = _stack_end + _prefix_size ;
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
* Interrupt Descriptor Table (IDT) setup and interrupt handlers for GDB stub.
|
* Interrupt Descriptor Table (IDT) setup and interrupt handlers for GDB stub.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <virtaddr.h>
|
#include <librm.h>
|
||||||
|
|
||||||
#define SIZEOF_I386_REGS 32
|
#define SIZEOF_I386_REGS 32
|
||||||
#define SIZEOF_I386_FLAGS 4
|
#define SIZEOF_I386_FLAGS 4
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* Interrupt Descriptor Table
|
* Interrupt Descriptor Table
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".data16"
|
.section ".data16", "aw", @progbits
|
||||||
.globl idtr
|
.globl idtr
|
||||||
idtr:
|
idtr:
|
||||||
idt_limit:
|
idt_limit:
|
||||||
@@ -68,7 +68,7 @@ idt_fixed:
|
|||||||
* Destroys %ax, %bx, and %di.
|
* Destroys %ax, %bx, and %di.
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
.code16
|
.code16
|
||||||
.globl idt_init
|
.globl idt_init
|
||||||
idt_init:
|
idt_init:
|
||||||
@@ -100,7 +100,7 @@ idt_init:
|
|||||||
* Interrupt handlers
|
* Interrupt handlers
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text"
|
.section ".text", "ax", @progbits
|
||||||
.code32
|
.code32
|
||||||
|
|
||||||
/* POSIX signal numbers for reporting traps to GDB */
|
/* POSIX signal numbers for reporting traps to GDB */
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <virtaddr.h>
|
#include <gpxe/uaccess.h>
|
||||||
#include <gpxe/gdbstub.h>
|
#include <gpxe/gdbstub.h>
|
||||||
#include <gdbmach.h>
|
#include <gdbmach.h>
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ static void gdbmach_enable_hwbps ( void ) {
|
|||||||
__asm__ __volatile__ ( "movl %0, %%dr7\n" : : "r" ( dr7 ) );
|
__asm__ __volatile__ ( "movl %0, %%dr7\n" : : "r" ( dr7 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
__cdecl void gdbmach_handler ( int signo, gdbreg_t *regs ) {
|
__asmcall void gdbmach_handler ( int signo, gdbreg_t *regs ) {
|
||||||
gdbmach_disable_hwbps();
|
gdbmach_disable_hwbps();
|
||||||
gdbstub_handler ( signo, regs );
|
gdbstub_handler ( signo, regs );
|
||||||
gdbmach_enable_hwbps();
|
gdbmach_enable_hwbps();
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
#include <realmode.h>
|
|
||||||
#include <bios.h>
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Save power by halting the CPU until the next interrupt
|
|
||||||
**************************************************************************/
|
|
||||||
void cpu_nap ( void ) {
|
|
||||||
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
|
||||||
"hlt\n\t"
|
|
||||||
"cli\n\t" ) : : );
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <gpxe/io.h>
|
||||||
#include <pic8259.h>
|
#include <pic8259.h>
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
|
|
||||||
OUTPUT_ARCH(i386)
|
|
||||||
|
|
||||||
SECTIONS {
|
|
||||||
.prefix.udata : {
|
|
||||||
*(*)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
|
|
||||||
OUTPUT_ARCH(i386)
|
|
||||||
|
|
||||||
SECTIONS {
|
|
||||||
.prefix.zdata : {
|
|
||||||
*(*)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* RDTSC timer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <gpxe/timer.h>
|
||||||
|
#include <gpxe/timer2.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of TSC ticks per microsecond
|
||||||
|
*
|
||||||
|
* This is calibrated on the first use of the timer.
|
||||||
|
*/
|
||||||
|
static unsigned long rdtsc_ticks_per_usec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay for a fixed number of microseconds
|
||||||
|
*
|
||||||
|
* @v usecs Number of microseconds for which to delay
|
||||||
|
*/
|
||||||
|
static void rdtsc_udelay ( unsigned long usecs ) {
|
||||||
|
unsigned long start;
|
||||||
|
unsigned long elapsed;
|
||||||
|
|
||||||
|
/* Sanity guard, since we may divide by this */
|
||||||
|
if ( ! usecs )
|
||||||
|
usecs = 1;
|
||||||
|
|
||||||
|
start = currticks();
|
||||||
|
if ( rdtsc_ticks_per_usec ) {
|
||||||
|
/* Already calibrated; busy-wait until done */
|
||||||
|
do {
|
||||||
|
elapsed = ( currticks() - start );
|
||||||
|
} while ( elapsed < ( usecs * rdtsc_ticks_per_usec ) );
|
||||||
|
} else {
|
||||||
|
/* Not yet calibrated; use timer2 and calibrate
|
||||||
|
* based on result.
|
||||||
|
*/
|
||||||
|
timer2_udelay ( usecs );
|
||||||
|
elapsed = ( currticks() - start );
|
||||||
|
rdtsc_ticks_per_usec = ( elapsed / usecs );
|
||||||
|
DBG ( "RDTSC timer calibrated: %ld ticks in %ld usecs "
|
||||||
|
"(%ld MHz)\n", elapsed, usecs,
|
||||||
|
( rdtsc_ticks_per_usec << TSC_SHIFT ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of ticks per second
|
||||||
|
*
|
||||||
|
* @ret ticks_per_sec Number of ticks per second
|
||||||
|
*/
|
||||||
|
static unsigned long rdtsc_ticks_per_sec ( void ) {
|
||||||
|
|
||||||
|
/* Calibrate timer, if not already done */
|
||||||
|
if ( ! rdtsc_ticks_per_usec )
|
||||||
|
udelay ( 1 );
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
assert ( rdtsc_ticks_per_usec != 0 );
|
||||||
|
|
||||||
|
return ( rdtsc_ticks_per_usec * 1000 * 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
PROVIDE_TIMER ( rdtsc, udelay, rdtsc_udelay );
|
||||||
|
PROVIDE_TIMER_INLINE ( rdtsc, currticks );
|
||||||
|
PROVIDE_TIMER ( rdtsc, ticks_per_sec, rdtsc_ticks_per_sec );
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
/* Real-mode interface: C portions.
|
|
||||||
*
|
|
||||||
* Initial version by Michael Brown <mbrown@fensystems.co.uk>, January 2004.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "realmode.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy data to/from base memory.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef KEEP_IT_REAL
|
|
||||||
|
|
||||||
void memcpy_to_real ( segoff_t dest, void *src, size_t n ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void memcpy_from_real ( void *dest, segoff_t src, size_t n ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* KEEP_IT_REAL */
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <io.h>
|
#include <gpxe/io.h>
|
||||||
#include <registers.h>
|
#include <registers.h>
|
||||||
#include <gpxe/memmap.h>
|
#include <gpxe/memmap.h>
|
||||||
|
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The linker passes in the symbol _max_align, which is the alignment
|
* The linker passes in the symbol _max_align, which is the alignment
|
||||||
* that we must preserve, in bytes.
|
* that we must preserve, in bytes.
|
||||||
@@ -18,8 +20,8 @@ extern char _max_align[];
|
|||||||
#define max_align ( ( unsigned int ) _max_align )
|
#define max_align ( ( unsigned int ) _max_align )
|
||||||
|
|
||||||
/* Linker symbols */
|
/* Linker symbols */
|
||||||
extern char _text[];
|
extern char _textdata[];
|
||||||
extern char _end[];
|
extern char _etextdata[];
|
||||||
|
|
||||||
/* within 1MB of 4GB is too close.
|
/* within 1MB of 4GB is too close.
|
||||||
* MAX_ADDR is the maximum address we can easily do DMA to.
|
* MAX_ADDR is the maximum address we can easily do DMA to.
|
||||||
@@ -39,7 +41,7 @@ extern char _end[];
|
|||||||
* address space, and returns the physical address of the new location
|
* address space, and returns the physical address of the new location
|
||||||
* to the prefix in %edi.
|
* to the prefix in %edi.
|
||||||
*/
|
*/
|
||||||
__cdecl void relocate ( struct i386_all_regs *ix86 ) {
|
__asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
||||||
struct memory_map memmap;
|
struct memory_map memmap;
|
||||||
unsigned long start, end, size, padded_size;
|
unsigned long start, end, size, padded_size;
|
||||||
unsigned long new_start, new_end;
|
unsigned long new_start, new_end;
|
||||||
@@ -47,8 +49,8 @@ __cdecl void relocate ( struct i386_all_regs *ix86 ) {
|
|||||||
|
|
||||||
/* Get memory map and current location */
|
/* Get memory map and current location */
|
||||||
get_memmap ( &memmap );
|
get_memmap ( &memmap );
|
||||||
start = virt_to_phys ( _text );
|
start = virt_to_phys ( _textdata );
|
||||||
end = virt_to_phys ( _end );
|
end = virt_to_phys ( _etextdata );
|
||||||
size = ( end - start );
|
size = ( end - start );
|
||||||
padded_size = ( size + max_align - 1 );
|
padded_size = ( size + max_align - 1 );
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/* setjmp and longjmp. Use of these functions is deprecated. */
|
/* setjmp and longjmp. Use of these functions is deprecated. */
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER )
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.code32
|
.code32
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
FILE_LICENCE ( GPL2_OR_LATER )
|
||||||
|
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Internal stack
|
* Internal stack
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".stack"
|
.section ".stack", "aw", @nobits
|
||||||
.align 8
|
.align 8
|
||||||
.globl _stack
|
.globl _stack
|
||||||
_stack:
|
_stack:
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
FILE_LICENCE ( GPL2_OR_LATER )
|
||||||
|
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Internal stack
|
* Internal stack
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".stack16"
|
.section ".stack16", "aw", @nobits
|
||||||
.align 8
|
.align 8
|
||||||
.globl _stack16
|
.globl _stack16
|
||||||
_stack16:
|
_stack16:
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
/* When linking with an uncompressed image, these symbols are not
|
|
||||||
* defined so we provide them here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__decompressor_uncompressed = 0 ;
|
|
||||||
__decompressor__start = 0 ;
|
|
||||||
|
|
||||||
INCLUDE arch/i386/core/start16z.lds
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
|
|
||||||
OUTPUT_ARCH(i386)
|
|
||||||
|
|
||||||
/* Linker-generated symbols are prefixed with a double underscore.
|
|
||||||
* Decompressor symbols are prefixed with __decompressor_. All other
|
|
||||||
* symbols are the same as in the original object file, i.e. the
|
|
||||||
* runtime addresses.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ENTRY(_start16)
|
|
||||||
|
|
||||||
SECTIONS {
|
|
||||||
.text : {
|
|
||||||
*(.text)
|
|
||||||
}
|
|
||||||
.payload : {
|
|
||||||
__payload_start = .;
|
|
||||||
*(.data)
|
|
||||||
__payload_end = .;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* _payload_size is the size of the binary image appended to
|
|
||||||
* start16, in bytes.
|
|
||||||
*/
|
|
||||||
__payload_size = __payload_end - __payload_start ;
|
|
||||||
|
|
||||||
/* _size is the size of the runtime image
|
|
||||||
* (start32 + the C code), in bytes.
|
|
||||||
*/
|
|
||||||
__size = _end - _start ;
|
|
||||||
|
|
||||||
/* _decompressor_size is the size of the decompressor, in
|
|
||||||
* bytes. For a non-compressed image, start16.lds sets
|
|
||||||
* _decompressor_uncompressed = _decompressor__start = 0.
|
|
||||||
*/
|
|
||||||
__decompressor_size = __decompressor_uncompressed - __decompressor__start ;
|
|
||||||
|
|
||||||
/* image__size is the total size of the image, after
|
|
||||||
* decompression and including the decompressor if applicable.
|
|
||||||
* It is therefore the amount of memory that start16's payload
|
|
||||||
* needs in order to execute, in bytes.
|
|
||||||
*/
|
|
||||||
__image_size = __size + __decompressor_size ;
|
|
||||||
|
|
||||||
/* Amount to add to runtime symbols to obtain the offset of
|
|
||||||
* that symbol within the image.
|
|
||||||
*/
|
|
||||||
__offset_adjust = __decompressor_size - _start ;
|
|
||||||
|
|
||||||
/* Calculations for the stack
|
|
||||||
*/
|
|
||||||
__stack_size = _estack - _stack ;
|
|
||||||
__offset_stack = _stack + __offset_adjust ;
|
|
||||||
|
|
||||||
/* Some symbols will be larger than 16 bits but guaranteed to
|
|
||||||
* be multiples of 16. We calculate them in paragraphs and
|
|
||||||
* export these symbols which can be used in 16-bit code
|
|
||||||
* without risk of overflow.
|
|
||||||
*/
|
|
||||||
__image_size_pgh = ( __image_size / 16 );
|
|
||||||
__start_pgh = ( _start / 16 );
|
|
||||||
__decompressor_size_pgh = ( __decompressor_size / 16 );
|
|
||||||
__offset_stack_pgh = ( __offset_stack / 16 );
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,325 +0,0 @@
|
|||||||
#include "virtaddr.h"
|
|
||||||
|
|
||||||
.equ MSR_K6_EFER, 0xC0000080
|
|
||||||
.equ EFER_LME, 0x00000100
|
|
||||||
.equ X86_CR4_PAE, 0x00000020
|
|
||||||
.equ CR0_PG, 0x80000000
|
|
||||||
|
|
||||||
#ifdef GAS291
|
|
||||||
#define DATA32 data32;
|
|
||||||
#define ADDR32 addr32;
|
|
||||||
#define LJMPI(x) ljmp x
|
|
||||||
#else
|
|
||||||
#define DATA32 data32
|
|
||||||
#define ADDR32 addr32
|
|
||||||
/* newer GAS295 require #define LJMPI(x) ljmp *x */
|
|
||||||
#define LJMPI(x) ljmp x
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: if you write a subroutine that is called from C code (gcc/egcs),
|
|
||||||
* then you only have to take care of %ebx, %esi, %edi and %ebp. These
|
|
||||||
* registers must not be altered under any circumstance. All other registers
|
|
||||||
* may be clobbered without any negative side effects. If you don't follow
|
|
||||||
* this rule then you'll run into strange effects that only occur on some
|
|
||||||
* gcc versions (because the register allocator may use different registers).
|
|
||||||
*
|
|
||||||
* All the data32 prefixes for the ljmp instructions are necessary, because
|
|
||||||
* the assembler emits code with a relocation address of 0. This means that
|
|
||||||
* all destinations are initially negative, which the assembler doesn't grok,
|
|
||||||
* because for some reason negative numbers don't fit into 16 bits. The addr32
|
|
||||||
* prefixes are there for the same reasons, because otherwise the memory
|
|
||||||
* references are only 16 bit wide. Theoretically they are all superfluous.
|
|
||||||
* One last note about prefixes: the data32 prefixes on all call _real_to_prot
|
|
||||||
* instructions could be removed if the _real_to_prot function is changed to
|
|
||||||
* deal correctly with 16 bit return addresses. I tried it, but failed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
.text
|
|
||||||
.arch i386
|
|
||||||
.code32
|
|
||||||
|
|
||||||
/* This is a struct os_entry_regs */
|
|
||||||
.globl os_regs
|
|
||||||
os_regs: .space 56
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
XSTART32 - Transfer control to the kernel just loaded
|
|
||||||
**************************************************************************/
|
|
||||||
.globl xstart32
|
|
||||||
xstart32:
|
|
||||||
/* Save the callee save registers */
|
|
||||||
movl %ebp, os_regs + 32
|
|
||||||
movl %esi, os_regs + 36
|
|
||||||
movl %edi, os_regs + 40
|
|
||||||
movl %ebx, os_regs + 44
|
|
||||||
|
|
||||||
/* save the return address */
|
|
||||||
popl %eax
|
|
||||||
movl %eax, os_regs + 48
|
|
||||||
|
|
||||||
/* save the stack pointer */
|
|
||||||
movl %esp, os_regs + 52
|
|
||||||
|
|
||||||
/* Get the new destination address */
|
|
||||||
popl %ecx
|
|
||||||
|
|
||||||
/* Store the physical address of xend on the stack */
|
|
||||||
movl $xend32, %ebx
|
|
||||||
addl virt_offset, %ebx
|
|
||||||
pushl %ebx
|
|
||||||
|
|
||||||
/* Store the destination address on the stack */
|
|
||||||
pushl $PHYSICAL_CS
|
|
||||||
pushl %ecx
|
|
||||||
|
|
||||||
/* Cache virt_offset */
|
|
||||||
movl virt_offset, %ebp
|
|
||||||
|
|
||||||
/* Switch to using physical addresses */
|
|
||||||
call _virt_to_phys
|
|
||||||
|
|
||||||
/* Save the target stack pointer */
|
|
||||||
movl %esp, os_regs + 12(%ebp)
|
|
||||||
leal os_regs(%ebp), %esp
|
|
||||||
|
|
||||||
/* Store the pointer to os_regs */
|
|
||||||
movl %esp, os_regs_ptr(%ebp)
|
|
||||||
|
|
||||||
/* Load my new registers */
|
|
||||||
popal
|
|
||||||
movl (-32 + 12)(%esp), %esp
|
|
||||||
|
|
||||||
/* Jump to the new kernel
|
|
||||||
* The lret switches to a flat code segment
|
|
||||||
*/
|
|
||||||
lret
|
|
||||||
|
|
||||||
.balign 4
|
|
||||||
.globl xend32
|
|
||||||
xend32:
|
|
||||||
/* Fixup %eflags */
|
|
||||||
nop
|
|
||||||
cli
|
|
||||||
cld
|
|
||||||
|
|
||||||
/* Load %esp with &os_regs + virt_offset */
|
|
||||||
.byte 0xbc /* movl $0, %esp */
|
|
||||||
os_regs_ptr:
|
|
||||||
.long 0
|
|
||||||
|
|
||||||
/* Save the result registers */
|
|
||||||
addl $32, %esp
|
|
||||||
pushal
|
|
||||||
|
|
||||||
/* Compute virt_offset */
|
|
||||||
movl %esp, %ebp
|
|
||||||
subl $os_regs, %ebp
|
|
||||||
|
|
||||||
/* Load the stack pointer and convert it to physical address */
|
|
||||||
movl 52(%esp), %esp
|
|
||||||
addl %ebp, %esp
|
|
||||||
|
|
||||||
/* Enable the virtual addresses */
|
|
||||||
leal _phys_to_virt(%ebp), %eax
|
|
||||||
call *%eax
|
|
||||||
|
|
||||||
/* Restore the callee save registers */
|
|
||||||
movl os_regs + 32, %ebp
|
|
||||||
movl os_regs + 36, %esi
|
|
||||||
movl os_regs + 40, %edi
|
|
||||||
movl os_regs + 44, %ebx
|
|
||||||
movl os_regs + 48, %edx
|
|
||||||
movl os_regs + 52, %esp
|
|
||||||
|
|
||||||
/* Get the C return value */
|
|
||||||
movl os_regs + 28, %eax
|
|
||||||
|
|
||||||
jmpl *%edx
|
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
|
||||||
.arch sledgehammer
|
|
||||||
/**************************************************************************
|
|
||||||
XSTART_lm - Transfer control to the kernel just loaded in long mode
|
|
||||||
**************************************************************************/
|
|
||||||
.globl xstart_lm
|
|
||||||
xstart_lm:
|
|
||||||
/* Save the callee save registers */
|
|
||||||
pushl %ebp
|
|
||||||
pushl %esi
|
|
||||||
pushl %edi
|
|
||||||
pushl %ebx
|
|
||||||
|
|
||||||
/* Cache virt_offset && (virt_offset & 0xfffff000) */
|
|
||||||
movl virt_offset, %ebp
|
|
||||||
movl %ebp, %ebx
|
|
||||||
andl $0xfffff000, %ebx
|
|
||||||
|
|
||||||
/* Switch to using physical addresses */
|
|
||||||
call _virt_to_phys
|
|
||||||
|
|
||||||
/* Initialize the page tables */
|
|
||||||
/* Level 4 */
|
|
||||||
leal 0x23 + pgt_level3(%ebx), %eax
|
|
||||||
leal pgt_level4(%ebx), %edi
|
|
||||||
movl %eax, (%edi)
|
|
||||||
|
|
||||||
/* Level 3 */
|
|
||||||
leal 0x23 + pgt_level2(%ebx), %eax
|
|
||||||
leal pgt_level3(%ebx), %edi
|
|
||||||
movl %eax, 0x00(%edi)
|
|
||||||
addl $4096, %eax
|
|
||||||
movl %eax, 0x08(%edi)
|
|
||||||
addl $4096, %eax
|
|
||||||
movl %eax, 0x10(%edi)
|
|
||||||
addl $4096, %eax
|
|
||||||
movl %eax, 0x18(%edi)
|
|
||||||
|
|
||||||
/* Level 2 */
|
|
||||||
movl $0xe3, %eax
|
|
||||||
leal pgt_level2(%ebx), %edi
|
|
||||||
leal 16384(%edi), %esi
|
|
||||||
pgt_level2_loop:
|
|
||||||
movl %eax, (%edi)
|
|
||||||
addl $8, %edi
|
|
||||||
addl $0x200000, %eax
|
|
||||||
cmp %esi, %edi
|
|
||||||
jne pgt_level2_loop
|
|
||||||
|
|
||||||
/* Point at the x86_64 page tables */
|
|
||||||
leal pgt_level4(%ebx), %edi
|
|
||||||
movl %edi, %cr3
|
|
||||||
|
|
||||||
|
|
||||||
/* Setup for the return from 64bit mode */
|
|
||||||
/* 64bit align the stack */
|
|
||||||
movl %esp, %ebx /* original stack pointer + 16 */
|
|
||||||
andl $0xfffffff8, %esp
|
|
||||||
|
|
||||||
/* Save original stack pointer + 16 */
|
|
||||||
pushl %ebx
|
|
||||||
|
|
||||||
/* Save virt_offset */
|
|
||||||
pushl %ebp
|
|
||||||
|
|
||||||
/* Setup for the jmp to 64bit long mode */
|
|
||||||
leal start_lm(%ebp), %eax
|
|
||||||
movl %eax, 0x00 + start_lm_addr(%ebp)
|
|
||||||
movl $LM_CODE_SEG, %eax
|
|
||||||
movl %eax, 0x04 + start_lm_addr(%ebp)
|
|
||||||
|
|
||||||
/* Setup for the jump out of 64bit long mode */
|
|
||||||
leal end_lm(%ebp), %eax
|
|
||||||
movl %eax, 0x00 + end_lm_addr(%ebp)
|
|
||||||
movl $FLAT_CODE_SEG, %eax
|
|
||||||
movl %eax, 0x04 + end_lm_addr(%ebp)
|
|
||||||
|
|
||||||
/* Enable PAE mode */
|
|
||||||
movl %cr4, %eax
|
|
||||||
orl $X86_CR4_PAE, %eax
|
|
||||||
movl %eax, %cr4
|
|
||||||
|
|
||||||
/* Enable long mode */
|
|
||||||
movl $MSR_K6_EFER, %ecx
|
|
||||||
rdmsr
|
|
||||||
orl $EFER_LME, %eax
|
|
||||||
wrmsr
|
|
||||||
|
|
||||||
/* Start paging, entering 32bit compatiblity mode */
|
|
||||||
movl %cr0, %eax
|
|
||||||
orl $CR0_PG, %eax
|
|
||||||
movl %eax, %cr0
|
|
||||||
|
|
||||||
/* Enter 64bit long mode */
|
|
||||||
ljmp *start_lm_addr(%ebp)
|
|
||||||
.code64
|
|
||||||
start_lm:
|
|
||||||
/* Load 64bit data segments */
|
|
||||||
movl $LM_DATA_SEG, %eax
|
|
||||||
movl %eax, %ds
|
|
||||||
movl %eax, %es
|
|
||||||
movl %eax, %ss
|
|
||||||
|
|
||||||
andq $0xffffffff, %rbx
|
|
||||||
/* Get the address to jump to */
|
|
||||||
movl 20(%rbx), %edx
|
|
||||||
andq $0xffffffff, %rdx
|
|
||||||
|
|
||||||
/* Get the argument pointer */
|
|
||||||
movl 24(%rbx), %ebx
|
|
||||||
andq $0xffffffff, %rbx
|
|
||||||
|
|
||||||
/* Jump to the 64bit code */
|
|
||||||
call *%rdx
|
|
||||||
|
|
||||||
/* Preserve the result */
|
|
||||||
movl %eax, %edx
|
|
||||||
|
|
||||||
/* Fixup %eflags */
|
|
||||||
cli
|
|
||||||
cld
|
|
||||||
|
|
||||||
/* Switch to 32bit compatibility mode */
|
|
||||||
ljmp *end_lm_addr(%rip)
|
|
||||||
|
|
||||||
.code32
|
|
||||||
end_lm:
|
|
||||||
/* Disable paging */
|
|
||||||
movl %cr0, %eax
|
|
||||||
andl $~CR0_PG, %eax
|
|
||||||
movl %eax, %cr0
|
|
||||||
|
|
||||||
/* Disable long mode */
|
|
||||||
movl $MSR_K6_EFER, %ecx
|
|
||||||
rdmsr
|
|
||||||
andl $~EFER_LME, %eax
|
|
||||||
wrmsr
|
|
||||||
|
|
||||||
/* Disable PAE */
|
|
||||||
movl %cr4, %eax
|
|
||||||
andl $~X86_CR4_PAE, %eax
|
|
||||||
movl %eax, %cr4
|
|
||||||
|
|
||||||
/* Compute virt_offset */
|
|
||||||
popl %ebp
|
|
||||||
|
|
||||||
/* Compute the original stack pointer + 16 */
|
|
||||||
popl %ebx
|
|
||||||
movl %ebx, %esp
|
|
||||||
|
|
||||||
/* Enable the virtual addresses */
|
|
||||||
leal _phys_to_virt(%ebp), %eax
|
|
||||||
call *%eax
|
|
||||||
|
|
||||||
/* Restore the callee save registers */
|
|
||||||
popl %ebx
|
|
||||||
popl %esi
|
|
||||||
popl %edi
|
|
||||||
popl %ebp
|
|
||||||
|
|
||||||
/* Get the C return value */
|
|
||||||
movl %edx, %eax
|
|
||||||
|
|
||||||
/* Return */
|
|
||||||
ret
|
|
||||||
|
|
||||||
.arch i386
|
|
||||||
#endif /* CONFIG_X86_64 */
|
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
|
||||||
.section ".bss"
|
|
||||||
.p2align 12
|
|
||||||
/* Include a dummy space in case we are loaded badly aligned */
|
|
||||||
.space 4096
|
|
||||||
/* Reserve enough space for a page table convering 4GB with 2MB pages */
|
|
||||||
pgt_level4:
|
|
||||||
.space 4096
|
|
||||||
pgt_level3:
|
|
||||||
.space 4096
|
|
||||||
pgt_level2:
|
|
||||||
.space 16384
|
|
||||||
start_lm_addr:
|
|
||||||
.space 8
|
|
||||||
end_lm_addr:
|
|
||||||
.space 8
|
|
||||||
#endif
|
|
||||||
@@ -11,13 +11,14 @@
|
|||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <bits/timer2.h>
|
#include <gpxe/timer2.h>
|
||||||
#include <gpxe/timer.h>
|
#include <gpxe/io.h>
|
||||||
#include <io.h>
|
|
||||||
|
|
||||||
/* Timers tick over at this rate */
|
/* Timers tick over at this rate */
|
||||||
#define TIMER2_TICK_RATE 1193180U
|
#define TIMER2_TICKS_PER_SEC 1193180U
|
||||||
|
|
||||||
/* Parallel Peripheral Controller Port B */
|
/* Parallel Peripheral Controller Port B */
|
||||||
#define PPC_PORTB 0x61
|
#define PPC_PORTB 0x61
|
||||||
@@ -52,8 +53,7 @@
|
|||||||
#define BINARY_COUNT 0x00
|
#define BINARY_COUNT 0x00
|
||||||
#define BCD_COUNT 0x01
|
#define BCD_COUNT 0x01
|
||||||
|
|
||||||
static void load_timer2(unsigned int ticks)
|
static void load_timer2 ( unsigned int ticks ) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Now let's take care of PPC channel 2
|
* Now let's take care of PPC channel 2
|
||||||
*
|
*
|
||||||
@@ -75,15 +75,13 @@ static void load_timer2(unsigned int ticks)
|
|||||||
outb(ticks >> 8, TIMER2_PORT);
|
outb(ticks >> 8, TIMER2_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int timer2_running(void)
|
static int timer2_running ( void ) {
|
||||||
{
|
|
||||||
return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
|
return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void i386_timer2_udelay(unsigned int usecs)
|
void timer2_udelay ( unsigned long usecs ) {
|
||||||
{
|
load_timer2 ( ( usecs * TIMER2_TICKS_PER_SEC ) / ( 1000 * 1000 ) );
|
||||||
load_timer2((usecs * TIMER2_TICK_RATE)/USECS_IN_SEC);
|
while (timer2_running()) {
|
||||||
while (timer2_running())
|
/* Do nothing */
|
||||||
;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "io.h"
|
#include <gpxe/io.h>
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include <gpxe/init.h>
|
#include <gpxe/init.h>
|
||||||
#include "vga.h"
|
#include "vga.h"
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "virtaddr.h"
|
FILE_LICENCE ( GPL2_OR_LATER )
|
||||||
|
|
||||||
|
#include "librm.h"
|
||||||
|
|
||||||
.arch i386
|
.arch i386
|
||||||
.text
|
.text
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <gpxe/io.h>
|
||||||
|
#include <gpxe/x86_io.h>
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* gPXE I/O API for x86
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read 64-bit qword from memory-mapped device
|
||||||
|
*
|
||||||
|
* @v io_addr I/O address
|
||||||
|
* @ret data Value read
|
||||||
|
*
|
||||||
|
* This routine uses MMX instructions.
|
||||||
|
*/
|
||||||
|
static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
|
||||||
|
uint64_t data;
|
||||||
|
__asm__ __volatile__ ( "pushl %%edx\n\t"
|
||||||
|
"pushl %%eax\n\t"
|
||||||
|
"movq (%1), %%mm0\n\t"
|
||||||
|
"movq %%mm0, (%%esp)\n\t"
|
||||||
|
"popl %%eax\n\t"
|
||||||
|
"popl %%edx\n\t"
|
||||||
|
"emms\n\t"
|
||||||
|
: "=A" ( data ) : "r" ( io_addr ) );
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write 64-bit qword to memory-mapped device
|
||||||
|
*
|
||||||
|
* @v data Value to write
|
||||||
|
* @v io_addr I/O address
|
||||||
|
*
|
||||||
|
* This routine uses MMX instructions.
|
||||||
|
*/
|
||||||
|
static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
|
||||||
|
__asm__ __volatile__ ( "pushl %%edx\n\t"
|
||||||
|
"pushl %%eax\n\t"
|
||||||
|
"movq (%%esp), %%mm0\n\t"
|
||||||
|
"movq %%mm0, (%1)\n\t"
|
||||||
|
"popl %%eax\n\t"
|
||||||
|
"popl %%edx\n\t"
|
||||||
|
"emms\n\t"
|
||||||
|
: : "A" ( data ), "r" ( io_addr ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, phys_to_bus );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, bus_to_phys );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, ioremap );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, iounmap );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, readb );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, readw );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, readl );
|
||||||
|
PROVIDE_IOAPI ( x86, readq, x86_readq );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, writeb );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, writew );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, writel );
|
||||||
|
PROVIDE_IOAPI ( x86, writeq, x86_writeq );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, inb );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, inw );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, inl );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, outb );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, outw );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, outl );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, insb );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, insw );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, insl );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, outsb );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, outsw );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, outsl );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, iodelay );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, mb );
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -135,7 +137,7 @@ static void undipci_remove ( struct pci_device *pci ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct pci_device_id undipci_nics[] = {
|
static struct pci_device_id undipci_nics[] = {
|
||||||
PCI_ROM ( 0xffff, 0xffff, "undipci", "UNDI (PCI)" ),
|
PCI_ROM ( 0xffff, 0xffff, "undipci", "UNDI (PCI)", 0 ),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pci_driver undipci_driver __pci_driver = {
|
struct pci_driver undipci_driver __pci_driver = {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
FILE_LICENCE ( GPL2_OR_LATER )
|
||||||
|
|
||||||
#define PXENV_UNDI_ISR 0x0014
|
#define PXENV_UNDI_ISR 0x0014
|
||||||
#define PXENV_UNDI_ISR_IN_START 1
|
#define PXENV_UNDI_ISR_IN_START 1
|
||||||
#define PXENV_UNDI_ISR_OUT_OURS 0
|
#define PXENV_UNDI_ISR_OUT_OURS 0
|
||||||
@@ -10,11 +12,9 @@
|
|||||||
|
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.section ".text16", "ax", @progbits
|
|
||||||
.section ".data16", "aw", @progbits
|
|
||||||
.code16
|
.code16
|
||||||
|
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
.globl undiisr
|
.globl undiisr
|
||||||
undiisr:
|
undiisr:
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ exit: /* Restore registers and return */
|
|||||||
popw %ds
|
popw %ds
|
||||||
iret
|
iret
|
||||||
|
|
||||||
.section ".data16"
|
.section ".data16", "aw", @progbits
|
||||||
undinet_params:
|
undinet_params:
|
||||||
status: .word 0
|
status: .word 0
|
||||||
funcflag: .word 0
|
funcflag: .word 0
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -90,11 +92,10 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
|
|||||||
undi_loader_entry = undirom->loader_entry;
|
undi_loader_entry = undirom->loader_entry;
|
||||||
__asm__ __volatile__ ( REAL_CODE ( "pushw %%ds\n\t"
|
__asm__ __volatile__ ( REAL_CODE ( "pushw %%ds\n\t"
|
||||||
"pushw %%ax\n\t"
|
"pushw %%ax\n\t"
|
||||||
"lcall *%c2\n\t"
|
"lcall *undi_loader_entry\n\t"
|
||||||
"addw $4, %%sp\n\t" )
|
"addw $4, %%sp\n\t" )
|
||||||
: "=a" ( exit )
|
: "=a" ( exit )
|
||||||
: "a" ( __from_data16 ( &undi_loader ) ),
|
: "a" ( __from_data16 ( &undi_loader ) )
|
||||||
"p" ( __from_data16 ( &undi_loader_entry ) )
|
|
||||||
: "ebx", "ecx", "edx", "esi", "edi", "ebp" );
|
: "ebx", "ecx", "edx", "esi", "edi", "ebp" );
|
||||||
|
|
||||||
/* UNDI API calls may rudely change the status of A20 and not
|
/* UNDI API calls may rudely change the status of A20 and not
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pxe.h>
|
#include <pxe.h>
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
#include <biosint.h>
|
#include <biosint.h>
|
||||||
#include <pnpbios.h>
|
#include <pnpbios.h>
|
||||||
#include <basemem_packet.h>
|
#include <basemem_packet.h>
|
||||||
|
#include <gpxe/io.h>
|
||||||
#include <gpxe/iobuf.h>
|
#include <gpxe/iobuf.h>
|
||||||
#include <gpxe/netdevice.h>
|
#include <gpxe/netdevice.h>
|
||||||
#include <gpxe/if_ether.h>
|
#include <gpxe/if_ether.h>
|
||||||
@@ -172,12 +175,11 @@ static int undinet_call ( struct undi_nic *undinic, unsigned int function,
|
|||||||
__asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
|
__asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
|
||||||
"pushw %%di\n\t"
|
"pushw %%di\n\t"
|
||||||
"pushw %%bx\n\t"
|
"pushw %%bx\n\t"
|
||||||
"lcall *%c3\n\t"
|
"lcall *undinet_entry_point\n\t"
|
||||||
"addw $6, %%sp\n\t" )
|
"addw $6, %%sp\n\t" )
|
||||||
: "=a" ( exit ), "=b" ( discard_b ),
|
: "=a" ( exit ), "=b" ( discard_b ),
|
||||||
"=D" ( discard_D )
|
"=D" ( discard_D )
|
||||||
: "p" ( __from_data16 ( &undinet_entry_point )),
|
: "b" ( function ),
|
||||||
"b" ( function ),
|
|
||||||
"D" ( __from_data16 ( &undinet_params ) )
|
"D" ( __from_data16 ( &undinet_params ) )
|
||||||
: "ecx", "edx", "esi", "ebp" );
|
: "ecx", "edx", "esi", "ebp" );
|
||||||
|
|
||||||
@@ -481,8 +483,7 @@ static void undinet_poll ( struct net_device *netdev ) {
|
|||||||
undi_isr.Frame.offset, frag_len );
|
undi_isr.Frame.offset, frag_len );
|
||||||
if ( iob_len ( iobuf ) == len ) {
|
if ( iob_len ( iobuf ) == len ) {
|
||||||
/* Whole packet received; deliver it */
|
/* Whole packet received; deliver it */
|
||||||
netdev_rx ( netdev, iobuf );
|
netdev_rx ( netdev, iob_disown ( iobuf ) );
|
||||||
iobuf = NULL;
|
|
||||||
/* Etherboot 5.4 fails to return all packets
|
/* Etherboot 5.4 fails to return all packets
|
||||||
* under mild load; pretend it retriggered.
|
* under mild load; pretend it retriggered.
|
||||||
*/
|
*/
|
||||||
@@ -669,22 +670,26 @@ int undinet_probe ( struct undi_device *undi ) {
|
|||||||
undi->flags |= UNDI_FL_STARTED;
|
undi->flags |= UNDI_FL_STARTED;
|
||||||
|
|
||||||
/* Bring up UNDI stack */
|
/* Bring up UNDI stack */
|
||||||
memset ( &undi_startup, 0, sizeof ( undi_startup ) );
|
if ( ! ( undi->flags & UNDI_FL_INITIALIZED ) ) {
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP, &undi_startup,
|
memset ( &undi_startup, 0, sizeof ( undi_startup ) );
|
||||||
sizeof ( undi_startup ) ) ) != 0 )
|
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP,
|
||||||
goto err_undi_startup;
|
&undi_startup,
|
||||||
memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
|
sizeof ( undi_startup ) ) ) != 0 )
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
|
goto err_undi_startup;
|
||||||
&undi_initialize,
|
memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
|
||||||
sizeof ( undi_initialize ) ) ) != 0 )
|
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
|
||||||
goto err_undi_initialize;
|
&undi_initialize,
|
||||||
|
sizeof ( undi_initialize ))) != 0 )
|
||||||
|
goto err_undi_initialize;
|
||||||
|
}
|
||||||
|
undi->flags |= UNDI_FL_INITIALIZED;
|
||||||
|
|
||||||
/* Get device information */
|
/* Get device information */
|
||||||
memset ( &undi_info, 0, sizeof ( undi_info ) );
|
memset ( &undi_info, 0, sizeof ( undi_info ) );
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_GET_INFORMATION,
|
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_GET_INFORMATION,
|
||||||
&undi_info, sizeof ( undi_info ) ) ) != 0 )
|
&undi_info, sizeof ( undi_info ) ) ) != 0 )
|
||||||
goto err_undi_get_information;
|
goto err_undi_get_information;
|
||||||
memcpy ( netdev->ll_addr, undi_info.PermNodeAddress, ETH_ALEN );
|
memcpy ( netdev->hw_addr, undi_info.PermNodeAddress, ETH_ALEN );
|
||||||
undinic->irq = undi_info.IntNumber;
|
undinic->irq = undi_info.IntNumber;
|
||||||
if ( undinic->irq > IRQ_MAX ) {
|
if ( undinic->irq > IRQ_MAX ) {
|
||||||
DBGC ( undinic, "UNDINIC %p invalid IRQ %d\n",
|
DBGC ( undinic, "UNDINIC %p invalid IRQ %d\n",
|
||||||
@@ -692,7 +697,7 @@ int undinet_probe ( struct undi_device *undi ) {
|
|||||||
goto err_bad_irq;
|
goto err_bad_irq;
|
||||||
}
|
}
|
||||||
DBGC ( undinic, "UNDINIC %p is %s on IRQ %d\n",
|
DBGC ( undinic, "UNDINIC %p is %s on IRQ %d\n",
|
||||||
undinic, eth_ntoa ( netdev->ll_addr ), undinic->irq );
|
undinic, eth_ntoa ( netdev->hw_addr ), undinic->irq );
|
||||||
|
|
||||||
/* Get interface information */
|
/* Get interface information */
|
||||||
memset ( &undi_iface, 0, sizeof ( undi_iface ) );
|
memset ( &undi_iface, 0, sizeof ( undi_iface ) );
|
||||||
@@ -700,8 +705,9 @@ int undinet_probe ( struct undi_device *undi ) {
|
|||||||
&undi_iface,
|
&undi_iface,
|
||||||
sizeof ( undi_iface ) ) ) != 0 )
|
sizeof ( undi_iface ) ) ) != 0 )
|
||||||
goto err_undi_get_iface_info;
|
goto err_undi_get_iface_info;
|
||||||
DBGC ( undinic, "UNDINIC %p has type %s and link speed %ld\n",
|
DBGC ( undinic, "UNDINIC %p has type %s, speed %d, flags %08x\n",
|
||||||
undinic, undi_iface.IfaceType, undi_iface.LinkSpeed );
|
undinic, undi_iface.IfaceType, undi_iface.LinkSpeed,
|
||||||
|
undi_iface.ServiceFlags );
|
||||||
if ( strncmp ( ( ( char * ) undi_iface.IfaceType ), "Etherboot",
|
if ( strncmp ( ( ( char * ) undi_iface.IfaceType ), "Etherboot",
|
||||||
sizeof ( undi_iface.IfaceType ) ) == 0 ) {
|
sizeof ( undi_iface.IfaceType ) ) == 0 ) {
|
||||||
DBGC ( undinic, "UNDINIC %p Etherboot 5.4 workaround enabled\n",
|
DBGC ( undinic, "UNDINIC %p Etherboot 5.4 workaround enabled\n",
|
||||||
@@ -731,11 +737,13 @@ int undinet_probe ( struct undi_device *undi ) {
|
|||||||
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
|
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
|
||||||
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
|
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
|
||||||
sizeof ( undi_cleanup ) );
|
sizeof ( undi_cleanup ) );
|
||||||
|
undi->flags &= ~UNDI_FL_INITIALIZED;
|
||||||
err_undi_startup:
|
err_undi_startup:
|
||||||
/* Unhook UNDI stack */
|
/* Unhook UNDI stack */
|
||||||
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
|
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
|
||||||
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
|
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
|
||||||
sizeof ( stop_undi ) );
|
sizeof ( stop_undi ) );
|
||||||
|
undi->flags &= ~UNDI_FL_STARTED;
|
||||||
err_start_undi:
|
err_start_undi:
|
||||||
netdev_nullify ( netdev );
|
netdev_nullify ( netdev );
|
||||||
netdev_put ( netdev );
|
netdev_put ( netdev );
|
||||||
@@ -758,19 +766,26 @@ void undinet_remove ( struct undi_device *undi ) {
|
|||||||
/* Unregister net device */
|
/* Unregister net device */
|
||||||
unregister_netdev ( netdev );
|
unregister_netdev ( netdev );
|
||||||
|
|
||||||
/* Shut down UNDI stack */
|
/* If we are preparing for an OS boot, or if we cannot exit
|
||||||
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
|
* via the PXE stack, then shut down the PXE stack.
|
||||||
undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
|
*/
|
||||||
sizeof ( undi_shutdown ) );
|
if ( ! ( undi->flags & UNDI_FL_KEEP_ALL ) ) {
|
||||||
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
|
|
||||||
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
|
|
||||||
sizeof ( undi_cleanup ) );
|
|
||||||
|
|
||||||
/* Unhook UNDI stack */
|
/* Shut down UNDI stack */
|
||||||
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
|
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
|
||||||
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
|
undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
|
||||||
sizeof ( stop_undi ) );
|
sizeof ( undi_shutdown ) );
|
||||||
undi->flags &= ~UNDI_FL_STARTED;
|
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
|
||||||
|
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
|
||||||
|
sizeof ( undi_cleanup ) );
|
||||||
|
undi->flags &= ~UNDI_FL_INITIALIZED;
|
||||||
|
|
||||||
|
/* Unhook UNDI stack */
|
||||||
|
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
|
||||||
|
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
|
||||||
|
sizeof ( stop_undi ) );
|
||||||
|
undi->flags &= ~UNDI_FL_STARTED;
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear entry point */
|
/* Clear entry point */
|
||||||
memset ( &undinet_entry_point, 0, sizeof ( undinet_entry_point ) );
|
memset ( &undinet_entry_point, 0, sizeof ( undinet_entry_point ) );
|
||||||
|
|||||||
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gpxe/device.h>
|
#include <gpxe/device.h>
|
||||||
|
#include <gpxe/init.h>
|
||||||
#include <undi.h>
|
#include <undi.h>
|
||||||
#include <undinet.h>
|
#include <undinet.h>
|
||||||
#include <undipreload.h>
|
#include <undipreload.h>
|
||||||
@@ -107,3 +110,20 @@ struct root_device undi_root_device __root_device = {
|
|||||||
.dev = { .name = "UNDI" },
|
.dev = { .name = "UNDI" },
|
||||||
.driver = &undi_root_driver,
|
.driver = &undi_root_driver,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare for exit
|
||||||
|
*
|
||||||
|
* @v flags Shutdown flags
|
||||||
|
*/
|
||||||
|
static void undionly_shutdown ( int flags ) {
|
||||||
|
/* If we are shutting down to boot an OS, clear the "keep PXE
|
||||||
|
* stack" flag.
|
||||||
|
*/
|
||||||
|
if ( flags & SHUTDOWN_BOOT )
|
||||||
|
preloaded_undi.flags &= ~UNDI_FL_KEEP_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct startup_fn startup_undionly __startup_fn ( STARTUP_LATE ) = {
|
||||||
|
.shutdown = undionly_shutdown,
|
||||||
|
};
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
#include <undipreload.h>
|
#include <undipreload.h>
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -52,7 +54,7 @@ static int undirom_parse_pxeromid ( struct undi_rom *undirom,
|
|||||||
sizeof ( undi_rom_id ) );
|
sizeof ( undi_rom_id ) );
|
||||||
if ( undi_rom_id.Signature != UNDI_ROM_ID_SIGNATURE ) {
|
if ( undi_rom_id.Signature != UNDI_ROM_ID_SIGNATURE ) {
|
||||||
DBGC ( undirom, "UNDIROM %p has bad PXE ROM ID signature "
|
DBGC ( undirom, "UNDIROM %p has bad PXE ROM ID signature "
|
||||||
"%08lx\n", undirom, undi_rom_id.Signature );
|
"%08x\n", undirom, undi_rom_id.Signature );
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +96,7 @@ static int undirom_parse_pcirheader ( struct undi_rom *undirom,
|
|||||||
sizeof ( pcir_header ) );
|
sizeof ( pcir_header ) );
|
||||||
if ( pcir_header.signature != PCIR_SIGNATURE ) {
|
if ( pcir_header.signature != PCIR_SIGNATURE ) {
|
||||||
DBGC ( undirom, "UNDIROM %p has bad PCI expansion header "
|
DBGC ( undirom, "UNDIROM %p has bad PCI expansion header "
|
||||||
"signature %08lx\n", undirom, pcir_header.signature );
|
"signature %08x\n", undirom, pcir_header.signature );
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Etherboot routines for PCBIOS firmware.
|
|
||||||
*
|
|
||||||
* Body of routines taken from old pcbios.S
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gpxe/init.h>
|
|
||||||
#include <gpxe/timer.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <realmode.h>
|
|
||||||
#include <bios.h>
|
|
||||||
#include <bits/timer2.h>
|
|
||||||
|
|
||||||
/* A bit faster actually, but we don't care. */
|
|
||||||
#define TIMER2_TICKS_PER_SEC 18
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use direct memory access to BIOS variables, longword 0040:006C (ticks
|
|
||||||
* today) and byte 0040:0070 (midnight crossover flag) instead of calling
|
|
||||||
* timeofday BIOS interrupt.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static tick_t bios_currticks ( void ) {
|
|
||||||
static int days = 0;
|
|
||||||
uint32_t ticks;
|
|
||||||
uint8_t midnight;
|
|
||||||
|
|
||||||
/* Re-enable interrupts so that the timer interrupt can occur */
|
|
||||||
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
|
||||||
"nop\n\t"
|
|
||||||
"nop\n\t"
|
|
||||||
"cli\n\t" ) : : );
|
|
||||||
|
|
||||||
get_real ( ticks, BDA_SEG, 0x006c );
|
|
||||||
get_real ( midnight, BDA_SEG, 0x0070 );
|
|
||||||
|
|
||||||
if ( midnight ) {
|
|
||||||
midnight = 0;
|
|
||||||
put_real ( midnight, BDA_SEG, 0x0070 );
|
|
||||||
days += 0x1800b0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( (days + ticks) * (USECS_IN_SEC / TIMER2_TICKS_PER_SEC) );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int bios_ts_init(void)
|
|
||||||
{
|
|
||||||
DBG("BIOS timer installed\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct timer bios_ts __timer ( 02 ) = {
|
|
||||||
.init = bios_ts_init,
|
|
||||||
.udelay = i386_timer2_udelay,
|
|
||||||
.currticks = bios_currticks,
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
|
|
||||||
#include <gpxe/init.h>
|
|
||||||
#include <gpxe/timer.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <bits/cpu.h>
|
|
||||||
#include <bits/timer2.h>
|
|
||||||
#include <io.h>
|
|
||||||
|
|
||||||
|
|
||||||
#define rdtsc(low,high) \
|
|
||||||
__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
|
|
||||||
|
|
||||||
#define rdtscll(val) \
|
|
||||||
__asm__ __volatile__ ("rdtsc" : "=A" (val))
|
|
||||||
|
|
||||||
|
|
||||||
/* Measure how many clocks we get in one microsecond */
|
|
||||||
static inline uint64_t calibrate_tsc(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
uint64_t rdtsc_start;
|
|
||||||
uint64_t rdtsc_end;
|
|
||||||
|
|
||||||
rdtscll(rdtsc_start);
|
|
||||||
i386_timer2_udelay(USECS_IN_MSEC);
|
|
||||||
rdtscll(rdtsc_end);
|
|
||||||
|
|
||||||
return (rdtsc_end - rdtsc_start) / USECS_IN_MSEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t clocks_per_usec = 0;
|
|
||||||
|
|
||||||
/* We measure time in microseconds. */
|
|
||||||
static tick_t rdtsc_currticks(void)
|
|
||||||
{
|
|
||||||
uint64_t clocks;
|
|
||||||
|
|
||||||
/* Read the Time Stamp Counter */
|
|
||||||
rdtscll(clocks);
|
|
||||||
|
|
||||||
return clocks / clocks_per_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rdtsc_ts_init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
struct cpuinfo_x86 cpu_info;
|
|
||||||
|
|
||||||
get_cpuinfo(&cpu_info);
|
|
||||||
if (cpu_info.features & X86_FEATURE_TSC) {
|
|
||||||
clocks_per_usec= calibrate_tsc();
|
|
||||||
if (clocks_per_usec) {
|
|
||||||
DBG("RDTSC ticksource installed. CPU running at %ld Mhz\n",
|
|
||||||
clocks_per_usec);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DBG("RDTSC ticksource not available on this machine.\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct timer rdtsc_ts __timer (01) = {
|
|
||||||
.init = rdtsc_ts_init,
|
|
||||||
.udelay = generic_currticks_udelay,
|
|
||||||
.currticks = rdtsc_currticks,
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
#include <bios.h>
|
#include <bios.h>
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
@@ -193,13 +195,14 @@ static const char *ansi_input = "";
|
|||||||
* dense range, so subtracting a constant and treating them as offsets
|
* dense range, so subtracting a constant and treating them as offsets
|
||||||
* into an array works efficiently.
|
* into an array works efficiently.
|
||||||
*/
|
*/
|
||||||
#define BIOS_KEY_MIN 0x47
|
#define BIOS_KEY_MIN 0x42
|
||||||
|
|
||||||
/** Offset into list of interesting BIOS scancodes */
|
/** Offset into list of interesting BIOS scancodes */
|
||||||
#define BIOS_KEY(scancode) ( (scancode) - BIOS_KEY_MIN )
|
#define BIOS_KEY(scancode) ( (scancode) - BIOS_KEY_MIN )
|
||||||
|
|
||||||
/** Mapping from BIOS scan codes to ANSI escape sequences */
|
/** Mapping from BIOS scan codes to ANSI escape sequences */
|
||||||
static const char *ansi_sequences[] = {
|
static const char *ansi_sequences[] = {
|
||||||
|
[ BIOS_KEY ( 0x42 ) ] = "[19~", /* F8 (required for PXE) */
|
||||||
[ BIOS_KEY ( 0x47 ) ] = "[H", /* Home */
|
[ BIOS_KEY ( 0x47 ) ] = "[H", /* Home */
|
||||||
[ BIOS_KEY ( 0x48 ) ] = "[A", /* Up arrow */
|
[ BIOS_KEY ( 0x48 ) ] = "[A", /* Up arrow */
|
||||||
[ BIOS_KEY ( 0x4b ) ] = "[D", /* Left arrow */
|
[ BIOS_KEY ( 0x4b ) ] = "[D", /* Left arrow */
|
||||||
@@ -222,6 +225,7 @@ static const char * scancode_to_ansi_seq ( unsigned int scancode ) {
|
|||||||
sizeof ( ansi_sequences[0] ) ) ) {
|
sizeof ( ansi_sequences[0] ) ) ) {
|
||||||
return ansi_sequences[bios_key];
|
return ansi_sequences[bios_key];
|
||||||
}
|
}
|
||||||
|
DBG ( "Unrecognised BIOS scancode %02x\n", scancode );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,11 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER )
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.section ".text16", "ax", @progbits
|
|
||||||
.section ".data16", "aw", @progbits
|
|
||||||
.section ".text16.data", "aw", @progbits
|
|
||||||
.code16
|
.code16
|
||||||
|
|
||||||
#define SMAP 0x534d4150
|
#define SMAP 0x534d4150
|
||||||
@@ -62,11 +61,11 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".data16"
|
.section ".data16", "aw", @progbits
|
||||||
.align 16
|
.align 16
|
||||||
.globl hidemem_base
|
.globl hidemem_base
|
||||||
.globl hidemem_umalloc
|
.globl hidemem_umalloc
|
||||||
.globl hidemem_text
|
.globl hidemem_textdata
|
||||||
memory_windows:
|
memory_windows:
|
||||||
base_memory_window: .long 0x00000000, 0x00000000 /* Start of memory */
|
base_memory_window: .long 0x00000000, 0x00000000 /* Start of memory */
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ ext_memory_window: .long 0x000a0000, 0x00000000 /* 640kB mark */
|
|||||||
hidemem_umalloc: .long 0xffffffff, 0xffffffff /* Changes at runtime */
|
hidemem_umalloc: .long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||||
.long 0xffffffff, 0xffffffff /* Changes at runtime */
|
.long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||||
|
|
||||||
hidemem_text: .long 0xffffffff, 0xffffffff /* Changes at runtime */
|
hidemem_textdata: .long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||||
.long 0xffffffff, 0xffffffff /* Changes at runtime */
|
.long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||||
|
|
||||||
.long 0xffffffff, 0xffffffff /* End of memory */
|
.long 0xffffffff, 0xffffffff /* End of memory */
|
||||||
@@ -94,7 +93,7 @@ memory_windows_end:
|
|||||||
* %ecx:%ebx Length of windowed region
|
* %ecx:%ebx Length of windowed region
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
window_region:
|
window_region:
|
||||||
/* Convert (start,len) to (start, end) */
|
/* Convert (start,len) to (start, end) */
|
||||||
addl %eax, %ebx
|
addl %eax, %ebx
|
||||||
@@ -132,7 +131,7 @@ window_region:
|
|||||||
* %ax Modified memory above 1M in 1kB blocks
|
* %ax Modified memory above 1M in 1kB blocks
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
patch_1m:
|
patch_1m:
|
||||||
pushal
|
pushal
|
||||||
/* Convert to (start,len) format and call truncate */
|
/* Convert to (start,len) format and call truncate */
|
||||||
@@ -162,7 +161,7 @@ patch_1m:
|
|||||||
* %bx Modified memory above 16M in 64kB blocks
|
* %bx Modified memory above 16M in 64kB blocks
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
patch_16m:
|
patch_16m:
|
||||||
pushal
|
pushal
|
||||||
/* Convert to (start,len) format and call truncate */
|
/* Convert to (start,len) format and call truncate */
|
||||||
@@ -193,7 +192,7 @@ patch_16m:
|
|||||||
* %bx Modified memory above 16MB, in 64kB blocks
|
* %bx Modified memory above 16MB, in 64kB blocks
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
patch_1m_16m:
|
patch_1m_16m:
|
||||||
call patch_1m
|
call patch_1m
|
||||||
call patch_16m
|
call patch_16m
|
||||||
@@ -219,7 +218,7 @@ patch_1m_16m:
|
|||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
get_underlying_e820:
|
get_underlying_e820:
|
||||||
|
|
||||||
/* If the requested region is in the cache, return it */
|
/* If the requested region is in the cache, return it */
|
||||||
@@ -268,8 +267,10 @@ get_underlying_e820:
|
|||||||
pushl %ebx
|
pushl %ebx
|
||||||
pushl %ecx
|
pushl %ecx
|
||||||
pushl %edx
|
pushl %edx
|
||||||
|
pushl %esi /* Some implementations corrupt %esi, so we */
|
||||||
|
pushl %edi /* preserve %esi, %edi and %ebp to be paranoid */
|
||||||
|
pushl %ebp
|
||||||
pushw %es
|
pushw %es
|
||||||
pushw %di
|
|
||||||
pushw %ds
|
pushw %ds
|
||||||
popw %es
|
popw %es
|
||||||
movw $underlying_e820_cache, %di
|
movw $underlying_e820_cache, %di
|
||||||
@@ -280,8 +281,10 @@ get_underlying_e820:
|
|||||||
stc
|
stc
|
||||||
pushfw
|
pushfw
|
||||||
lcall *%cs:int15_vector
|
lcall *%cs:int15_vector
|
||||||
popw %di
|
|
||||||
popw %es
|
popw %es
|
||||||
|
popl %ebp
|
||||||
|
popl %edi
|
||||||
|
popl %esi
|
||||||
/* Check for error return from underlying e820 call */
|
/* Check for error return from underlying e820 call */
|
||||||
jc 2f /* CF set: error */
|
jc 2f /* CF set: error */
|
||||||
cmpl $SMAP, %eax
|
cmpl $SMAP, %eax
|
||||||
@@ -304,22 +307,22 @@ get_underlying_e820:
|
|||||||
jmp get_underlying_e820
|
jmp get_underlying_e820
|
||||||
.size get_underlying_e820, . - get_underlying_e820
|
.size get_underlying_e820, . - get_underlying_e820
|
||||||
|
|
||||||
.section ".data16"
|
.section ".data16", "aw", @progbits
|
||||||
underlying_e820_index:
|
underlying_e820_index:
|
||||||
.word 0xffff /* Initialise to an invalid value */
|
.word 0xffff /* Initialise to an invalid value */
|
||||||
.size underlying_e820_index, . - underlying_e820_index
|
.size underlying_e820_index, . - underlying_e820_index
|
||||||
|
|
||||||
.section ".bss16"
|
.section ".bss16", "aw", @nobits
|
||||||
underlying_e820_ebx:
|
underlying_e820_ebx:
|
||||||
.long 0
|
.long 0
|
||||||
.size underlying_e820_ebx, . - underlying_e820_ebx
|
.size underlying_e820_ebx, . - underlying_e820_ebx
|
||||||
|
|
||||||
.section ".bss16"
|
.section ".bss16", "aw", @nobits
|
||||||
underlying_e820_cache:
|
underlying_e820_cache:
|
||||||
.space E820MAXSIZE
|
.space E820MAXSIZE
|
||||||
.size underlying_e820_cache, . - underlying_e820_cache
|
.size underlying_e820_cache, . - underlying_e820_cache
|
||||||
|
|
||||||
.section ".bss16"
|
.section ".bss16", "aw", @nobits
|
||||||
underlying_e820_cache_size:
|
underlying_e820_cache_size:
|
||||||
.long 0
|
.long 0
|
||||||
.size underlying_e820_cache_size, . - underlying_e820_cache_size
|
.size underlying_e820_cache_size, . - underlying_e820_cache_size
|
||||||
@@ -338,7 +341,7 @@ underlying_e820_cache_size:
|
|||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
get_windowed_e820:
|
get_windowed_e820:
|
||||||
|
|
||||||
/* Preserve registers */
|
/* Preserve registers */
|
||||||
@@ -413,7 +416,7 @@ get_windowed_e820:
|
|||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
get_nonempty_e820:
|
get_nonempty_e820:
|
||||||
|
|
||||||
/* Record entry parameters */
|
/* Record entry parameters */
|
||||||
@@ -458,7 +461,7 @@ get_nonempty_e820:
|
|||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
get_mangled_e820:
|
get_mangled_e820:
|
||||||
|
|
||||||
/* Get a nonempty region */
|
/* Get a nonempty region */
|
||||||
@@ -488,30 +491,43 @@ get_mangled_e820:
|
|||||||
ret
|
ret
|
||||||
.size get_mangled_e820, . - get_mangled_e820
|
.size get_mangled_e820, . - get_mangled_e820
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Set/clear CF on the stack as appropriate, assumes stack is as it should
|
||||||
|
* be immediately before IRET
|
||||||
|
****************************************************************************
|
||||||
|
*/
|
||||||
|
patch_cf:
|
||||||
|
pushw %bp
|
||||||
|
movw %sp, %bp
|
||||||
|
setc 8(%bp) /* Set/reset CF; clears PF, AF, ZF, SF */
|
||||||
|
popw %bp
|
||||||
|
ret
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* INT 15,e820 handler
|
* INT 15,e820 handler
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
int15_e820:
|
int15_e820:
|
||||||
pushw %ds
|
pushw %ds
|
||||||
pushw %cs:rm_ds
|
pushw %cs:rm_ds
|
||||||
popw %ds
|
popw %ds
|
||||||
call get_mangled_e820
|
call get_mangled_e820
|
||||||
popw %ds
|
popw %ds
|
||||||
lret $2
|
call patch_cf
|
||||||
|
iret
|
||||||
.size int15_e820, . - int15_e820
|
.size int15_e820, . - int15_e820
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* INT 15,e801 handler
|
* INT 15,e801 handler
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
int15_e801:
|
int15_e801:
|
||||||
/* Call previous handler */
|
/* Call previous handler */
|
||||||
pushfw
|
pushfw
|
||||||
lcall *%cs:int15_vector
|
lcall *%cs:int15_vector
|
||||||
pushfw
|
call patch_cf
|
||||||
/* Edit result */
|
/* Edit result */
|
||||||
pushw %ds
|
pushw %ds
|
||||||
pushw %cs:rm_ds
|
pushw %cs:rm_ds
|
||||||
@@ -523,37 +539,33 @@ int15_e801:
|
|||||||
xchgw %ax, %cx
|
xchgw %ax, %cx
|
||||||
xchgw %bx, %dx
|
xchgw %bx, %dx
|
||||||
popw %ds
|
popw %ds
|
||||||
/* Restore flags returned by previous handler and return */
|
iret
|
||||||
popfw
|
|
||||||
lret $2
|
|
||||||
.size int15_e801, . - int15_e801
|
.size int15_e801, . - int15_e801
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* INT 15,88 handler
|
* INT 15,88 handler
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
int15_88:
|
int15_88:
|
||||||
/* Call previous handler */
|
/* Call previous handler */
|
||||||
pushfw
|
pushfw
|
||||||
lcall *%cs:int15_vector
|
lcall *%cs:int15_vector
|
||||||
pushfw
|
call patch_cf
|
||||||
/* Edit result */
|
/* Edit result */
|
||||||
pushw %ds
|
pushw %ds
|
||||||
pushw %cs:rm_ds
|
pushw %cs:rm_ds
|
||||||
popw %ds
|
popw %ds
|
||||||
call patch_1m
|
call patch_1m
|
||||||
popw %ds
|
popw %ds
|
||||||
/* Restore flags returned by previous handler and return */
|
iret
|
||||||
popfw
|
|
||||||
lret $2
|
|
||||||
.size int15_88, . - int15_88
|
.size int15_88, . - int15_88
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* INT 15 handler
|
* INT 15 handler
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".text16"
|
.section ".text16", "ax", @progbits
|
||||||
.globl int15
|
.globl int15
|
||||||
int15:
|
int15:
|
||||||
/* See if we want to intercept this call */
|
/* See if we want to intercept this call */
|
||||||
@@ -576,7 +588,7 @@ int15:
|
|||||||
ljmp *%cs:int15_vector
|
ljmp *%cs:int15_vector
|
||||||
.size int15, . - int15
|
.size int15, . - int15
|
||||||
|
|
||||||
.section ".text16.data"
|
.section ".text16.data", "aw", @progbits
|
||||||
.globl int15_vector
|
.globl int15_vector
|
||||||
int15_vector:
|
int15_vector:
|
||||||
.long 0
|
.long 0
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
#include <biosint.h>
|
#include <biosint.h>
|
||||||
|
|
||||||
@@ -63,6 +65,8 @@ void fake_e820 ( void ) {
|
|||||||
"cmpl $0x534d4150, %%edx\n\t"
|
"cmpl $0x534d4150, %%edx\n\t"
|
||||||
"jne 99f\n\t"
|
"jne 99f\n\t"
|
||||||
"pushaw\n\t"
|
"pushaw\n\t"
|
||||||
|
"movw %%sp, %%bp\n\t"
|
||||||
|
"andb $~0x01, 22(%%bp)\n\t" /* Clear return CF */
|
||||||
"leaw e820map(%%bx), %%si\n\t"
|
"leaw e820map(%%bx), %%si\n\t"
|
||||||
"cs rep movsb\n\t"
|
"cs rep movsb\n\t"
|
||||||
"popaw\n\t"
|
"popaw\n\t"
|
||||||
@@ -73,8 +77,7 @@ void fake_e820 ( void ) {
|
|||||||
"xorl %%ebx,%%ebx\n\t"
|
"xorl %%ebx,%%ebx\n\t"
|
||||||
"\n1:\n\t"
|
"\n1:\n\t"
|
||||||
"popfw\n\t"
|
"popfw\n\t"
|
||||||
"clc\n\t"
|
"iret\n\t"
|
||||||
"lret $2\n\t"
|
|
||||||
"\n99:\n\t"
|
"\n99:\n\t"
|
||||||
"popfw\n\t"
|
"popfw\n\t"
|
||||||
"ljmp *%%cs:real_int15_vector\n\t" )
|
"ljmp *%%cs:real_int15_vector\n\t" )
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
#include <bios.h>
|
#include <bios.h>
|
||||||
|
#include <gpxe/io.h>
|
||||||
#include <gpxe/timer.h>
|
#include <gpxe/timer.h>
|
||||||
|
|
||||||
#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
|
#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
|
||||||
@@ -48,9 +51,9 @@ static void empty_8042 ( void ) {
|
|||||||
time = currticks() + TICKS_PER_SEC; /* max wait of 1 second */
|
time = currticks() + TICKS_PER_SEC; /* max wait of 1 second */
|
||||||
while ( ( inb ( K_CMD ) & ( K_IBUF_FUL | K_OBUF_FUL ) ) &&
|
while ( ( inb ( K_CMD ) & ( K_IBUF_FUL | K_OBUF_FUL ) ) &&
|
||||||
currticks() < time ) {
|
currticks() < time ) {
|
||||||
SLOW_DOWN_IO;
|
iodelay();
|
||||||
( void ) inb ( K_RDWR );
|
( void ) inb_p ( K_RDWR );
|
||||||
SLOW_DOWN_IO;
|
iodelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ static int gateA20_is_set ( int retries ) {
|
|||||||
/* Avoid false negatives */
|
/* Avoid false negatives */
|
||||||
test_pattern++;
|
test_pattern++;
|
||||||
|
|
||||||
SLOW_DOWN_IO;
|
iodelay();
|
||||||
|
|
||||||
/* Always retry at least once, to avoid false negatives */
|
/* Always retry at least once, to avoid false negatives */
|
||||||
} while ( retries-- >= 0 );
|
} while ( retries-- >= 0 );
|
||||||
@@ -145,9 +148,9 @@ void gateA20_set ( void ) {
|
|||||||
scp_a = inb ( SCP_A );
|
scp_a = inb ( SCP_A );
|
||||||
scp_a &= ~0x01; /* Avoid triggering a reset */
|
scp_a &= ~0x01; /* Avoid triggering a reset */
|
||||||
scp_a |= 0x02; /* Enable A20 */
|
scp_a |= 0x02; /* Enable A20 */
|
||||||
SLOW_DOWN_IO;
|
iodelay();
|
||||||
outb ( scp_a, SCP_A );
|
outb ( scp_a, SCP_A );
|
||||||
SLOW_DOWN_IO;
|
iodelay();
|
||||||
if ( gateA20_is_set ( A20_SCPA_RETRIES ) ) {
|
if ( gateA20_is_set ( A20_SCPA_RETRIES ) ) {
|
||||||
DBG ( "Enabled gate A20 using "
|
DBG ( "Enabled gate A20 using "
|
||||||
"Fast Gate A20\n" );
|
"Fast Gate A20\n" );
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
#include <biosint.h>
|
#include <biosint.h>
|
||||||
@@ -55,8 +57,8 @@ extern struct hidden_region __data16 ( hidemem_umalloc );
|
|||||||
#define hidemem_umalloc __use_data16 ( hidemem_umalloc )
|
#define hidemem_umalloc __use_data16 ( hidemem_umalloc )
|
||||||
|
|
||||||
/** Hidden text memory */
|
/** Hidden text memory */
|
||||||
extern struct hidden_region __data16 ( hidemem_text );
|
extern struct hidden_region __data16 ( hidemem_textdata );
|
||||||
#define hidemem_text __use_data16 ( hidemem_text )
|
#define hidemem_textdata __use_data16 ( hidemem_textdata )
|
||||||
|
|
||||||
/** Assembly routine in e820mangler.S */
|
/** Assembly routine in e820mangler.S */
|
||||||
extern void int15();
|
extern void int15();
|
||||||
@@ -66,12 +68,12 @@ extern struct segoff __text16 ( int15_vector );
|
|||||||
#define int15_vector __use_text16 ( int15_vector )
|
#define int15_vector __use_text16 ( int15_vector )
|
||||||
|
|
||||||
/* The linker defines these symbols for us */
|
/* The linker defines these symbols for us */
|
||||||
extern char _text[];
|
extern char _textdata[];
|
||||||
extern char _end[];
|
extern char _etextdata[];
|
||||||
extern char _text16_size[];
|
extern char _text16_memsz[];
|
||||||
#define _text16_size ( ( unsigned int ) _text16_size )
|
#define _text16_memsz ( ( unsigned int ) _text16_memsz )
|
||||||
extern char _data16_size[];
|
extern char _data16_memsz[];
|
||||||
#define _data16_size ( ( unsigned int ) _data16_size )
|
#define _data16_memsz ( ( unsigned int ) _data16_memsz )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide region of memory from system memory map
|
* Hide region of memory from system memory map
|
||||||
@@ -110,7 +112,7 @@ void hide_basemem ( void ) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void hide_umalloc ( physaddr_t start, physaddr_t end ) {
|
void hide_umalloc ( physaddr_t start, physaddr_t end ) {
|
||||||
assert ( end <= virt_to_phys ( _text ) );
|
assert ( end <= virt_to_phys ( _textdata ) );
|
||||||
hide_region ( &hidemem_umalloc, start, end );
|
hide_region ( &hidemem_umalloc, start, end );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,9 +120,9 @@ void hide_umalloc ( physaddr_t start, physaddr_t end ) {
|
|||||||
* Hide .text and .data
|
* Hide .text and .data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void hide_text ( void ) {
|
void hide_textdata ( void ) {
|
||||||
hide_region ( &hidemem_text, virt_to_phys ( _text ),
|
hide_region ( &hidemem_textdata, virt_to_phys ( _textdata ),
|
||||||
virt_to_phys ( _end ) );
|
virt_to_phys ( _etextdata ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,8 +150,8 @@ static void hide_etherboot ( void ) {
|
|||||||
|
|
||||||
/* Initialise the hidden regions */
|
/* Initialise the hidden regions */
|
||||||
hide_basemem();
|
hide_basemem();
|
||||||
hide_umalloc ( virt_to_phys ( _text ), virt_to_phys ( _text ) );
|
hide_umalloc ( virt_to_phys ( _textdata ), virt_to_phys ( _textdata ) );
|
||||||
hide_text();
|
hide_textdata();
|
||||||
|
|
||||||
/* Some really moronic BIOSes bring up the PXE stack via the
|
/* Some really moronic BIOSes bring up the PXE stack via the
|
||||||
* UNDI loader entry point and then don't bother to unload it
|
* UNDI loader entry point and then don't bother to unload it
|
||||||
@@ -161,8 +163,8 @@ static void hide_etherboot ( void ) {
|
|||||||
* We use a heuristic to guess whether or not we are being
|
* We use a heuristic to guess whether or not we are being
|
||||||
* loaded sensibly.
|
* loaded sensibly.
|
||||||
*/
|
*/
|
||||||
rm_cs_top = ( ( ( rm_cs << 4 ) + _text16_size + 1024 - 1 ) >> 10 );
|
rm_cs_top = ( ( ( rm_cs << 4 ) + _text16_memsz + 1024 - 1 ) >> 10 );
|
||||||
rm_ds_top = ( ( ( rm_ds << 4 ) + _data16_size + 1024 - 1 ) >> 10 );
|
rm_ds_top = ( ( ( rm_ds << 4 ) + _data16_memsz + 1024 - 1 ) >> 10 );
|
||||||
fbms = get_fbms();
|
fbms = get_fbms();
|
||||||
if ( ( rm_cs_top < fbms ) && ( rm_ds_top < fbms ) ) {
|
if ( ( rm_cs_top < fbms ) && ( rm_ds_top < fbms ) ) {
|
||||||
DBG ( "Detected potentially unsafe UNDI load at CS=%04x "
|
DBG ( "Detected potentially unsafe UNDI load at CS=%04x "
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
@@ -158,7 +160,7 @@ static int meme820 ( struct memory_map *memmap ) {
|
|||||||
uint32_t smap;
|
uint32_t smap;
|
||||||
size_t size;
|
size_t size;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
unsigned int discard_d, discard_D;
|
unsigned int discard_D;
|
||||||
|
|
||||||
/* Clear the E820 buffer. Do this once before starting,
|
/* Clear the E820 buffer. Do this once before starting,
|
||||||
* rather than on each call; some BIOSes rely on the contents
|
* rather than on each call; some BIOSes rely on the contents
|
||||||
@@ -167,18 +169,24 @@ static int meme820 ( struct memory_map *memmap ) {
|
|||||||
memset ( &e820buf, 0, sizeof ( e820buf ) );
|
memset ( &e820buf, 0, sizeof ( e820buf ) );
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
|
/* Some BIOSes corrupt %esi for fun. Guard against
|
||||||
|
* this by telling gcc that all non-output registers
|
||||||
|
* may be corrupted.
|
||||||
|
*/
|
||||||
|
__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t"
|
||||||
|
"stc\n\t"
|
||||||
"int $0x15\n\t"
|
"int $0x15\n\t"
|
||||||
"pushfw\n\t"
|
"pushfw\n\t"
|
||||||
"popw %w0\n\t" )
|
"popw %%dx\n\t"
|
||||||
: "=r" ( flags ), "=a" ( smap ),
|
"popl %%ebp\n\t" )
|
||||||
"=b" ( next ), "=D" ( discard_D ),
|
: "=a" ( smap ), "=b" ( next ),
|
||||||
"=c" ( size ), "=d" ( discard_d )
|
"=c" ( size ), "=d" ( flags ),
|
||||||
|
"=D" ( discard_D )
|
||||||
: "a" ( 0xe820 ), "b" ( next ),
|
: "a" ( 0xe820 ), "b" ( next ),
|
||||||
"D" ( __from_data16 ( &e820buf ) ),
|
"D" ( __from_data16 ( &e820buf ) ),
|
||||||
"c" ( sizeof ( e820buf ) ),
|
"c" ( sizeof ( e820buf ) ),
|
||||||
"d" ( SMAP )
|
"d" ( SMAP )
|
||||||
: "memory" );
|
: "esi", "memory" );
|
||||||
|
|
||||||
if ( smap != SMAP ) {
|
if ( smap != SMAP ) {
|
||||||
DBG ( "INT 15,e820 failed SMAP signature check\n" );
|
DBG ( "INT 15,e820 failed SMAP signature check\n" );
|
||||||
@@ -195,6 +203,13 @@ static int meme820 ( struct memory_map *memmap ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If first region is not RAM, assume map is invalid */
|
||||||
|
if ( ( memmap->count == 0 ) &&
|
||||||
|
( e820buf.type != E820_TYPE_RAM ) ) {
|
||||||
|
DBG ( "INT 15,e820 failed, first entry not RAM\n" );
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
DBG ( "INT 15,e820 region [%llx,%llx) type %d",
|
DBG ( "INT 15,e820 region [%llx,%llx) type %d",
|
||||||
e820buf.start, ( e820buf.start + e820buf.len ),
|
e820buf.start, ( e820buf.start + e820buf.len ),
|
||||||
( int ) e820buf.type );
|
( int ) e820buf.type );
|
||||||
@@ -204,7 +219,7 @@ static int meme820 ( struct memory_map *memmap ) {
|
|||||||
if ( e820buf.attrs & E820_ATTR_NONVOLATILE )
|
if ( e820buf.attrs & E820_ATTR_NONVOLATILE )
|
||||||
DBG ( ", non-volatile" );
|
DBG ( ", non-volatile" );
|
||||||
if ( e820buf.attrs & E820_ATTR_UNKNOWN )
|
if ( e820buf.attrs & E820_ATTR_UNKNOWN )
|
||||||
DBG ( ", other [%08lx]", e820buf.attrs );
|
DBG ( ", other [%08x]", e820buf.attrs );
|
||||||
DBG ( ")" );
|
DBG ( ")" );
|
||||||
}
|
}
|
||||||
DBG ( "\n" );
|
DBG ( "\n" );
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include <gpxe/netdevice.h>
|
||||||
|
#include <gpxe/command.h>
|
||||||
|
#include <hci/ifmgmt_cmd.h>
|
||||||
|
#include <pxe_call.h>
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
static int startpxe_payload ( struct net_device *netdev ) {
|
||||||
|
if ( netdev->state & NETDEV_OPEN )
|
||||||
|
pxe_activate ( netdev );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int startpxe_exec ( int argc, char **argv ) {
|
||||||
|
return ifcommon_exec ( argc, argv, startpxe_payload,
|
||||||
|
"Activate PXE on" );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int stoppxe_exec ( int argc __unused, char **argv __unused ) {
|
||||||
|
pxe_deactivate();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct command pxe_commands[] __command = {
|
||||||
|
{
|
||||||
|
.name = "startpxe",
|
||||||
|
.exec = startpxe_exec,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "stoppxe",
|
||||||
|
.exec = stoppxe_exec,
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
*
|
*
|
||||||
|
|||||||
+235
-250
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
*
|
*
|
||||||
@@ -42,9 +44,11 @@ FEATURE ( FEATURE_IMAGE, "bzImage", DHCP_EB_FEATURE_BZIMAGE, 1 );
|
|||||||
struct image_type bzimage_image_type __image_type ( PROBE_NORMAL );
|
struct image_type bzimage_image_type __image_type ( PROBE_NORMAL );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bzImage load context
|
* bzImage context
|
||||||
*/
|
*/
|
||||||
struct bzimage_load_context {
|
struct bzimage_context {
|
||||||
|
/** Boot protocol version */
|
||||||
|
unsigned int version;
|
||||||
/** Real-mode kernel portion load segment address */
|
/** Real-mode kernel portion load segment address */
|
||||||
unsigned int rm_kernel_seg;
|
unsigned int rm_kernel_seg;
|
||||||
/** Real-mode kernel portion load address */
|
/** Real-mode kernel portion load address */
|
||||||
@@ -55,28 +59,14 @@ struct bzimage_load_context {
|
|||||||
size_t rm_heap;
|
size_t rm_heap;
|
||||||
/** Command line (offset from rm_kernel) */
|
/** Command line (offset from rm_kernel) */
|
||||||
size_t rm_cmdline;
|
size_t rm_cmdline;
|
||||||
|
/** Command line maximum length */
|
||||||
|
size_t cmdline_size;
|
||||||
/** Real-mode kernel portion total memory size */
|
/** Real-mode kernel portion total memory size */
|
||||||
size_t rm_memsz;
|
size_t rm_memsz;
|
||||||
/** Non-real-mode kernel portion load address */
|
/** Non-real-mode kernel portion load address */
|
||||||
userptr_t pm_kernel;
|
userptr_t pm_kernel;
|
||||||
/** Non-real-mode kernel portion file and memory size */
|
/** Non-real-mode kernel portion file and memory size */
|
||||||
size_t pm_sz;
|
size_t pm_sz;
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bzImage execution context
|
|
||||||
*/
|
|
||||||
struct bzimage_exec_context {
|
|
||||||
/** Real-mode kernel portion load segment address */
|
|
||||||
unsigned int rm_kernel_seg;
|
|
||||||
/** Real-mode kernel portion load address */
|
|
||||||
userptr_t rm_kernel;
|
|
||||||
/** Real-mode heap top (offset from rm_kernel) */
|
|
||||||
size_t rm_heap;
|
|
||||||
/** Command line (offset from rm_kernel) */
|
|
||||||
size_t rm_cmdline;
|
|
||||||
/** Command line maximum length */
|
|
||||||
size_t cmdline_size;
|
|
||||||
/** Video mode */
|
/** Video mode */
|
||||||
unsigned int vid_mode;
|
unsigned int vid_mode;
|
||||||
/** Memory limit */
|
/** Memory limit */
|
||||||
@@ -85,18 +75,178 @@ struct bzimage_exec_context {
|
|||||||
physaddr_t ramdisk_image;
|
physaddr_t ramdisk_image;
|
||||||
/** Initrd size */
|
/** Initrd size */
|
||||||
physaddr_t ramdisk_size;
|
physaddr_t ramdisk_size;
|
||||||
|
|
||||||
|
/** Command line magic block */
|
||||||
|
struct bzimage_cmdline cmdline_magic;
|
||||||
|
/** bzImage header */
|
||||||
|
struct bzimage_header bzhdr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse bzImage header
|
||||||
|
*
|
||||||
|
* @v image bzImage file
|
||||||
|
* @v bzimg bzImage context
|
||||||
|
* @v src bzImage to parse
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
|
static int bzimage_parse_header ( struct image *image,
|
||||||
|
struct bzimage_context *bzimg,
|
||||||
|
userptr_t src ) {
|
||||||
|
unsigned int syssize;
|
||||||
|
int is_bzimage;
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
if ( image->len < ( BZI_HDR_OFFSET + sizeof ( bzimg->bzhdr ) ) ) {
|
||||||
|
DBGC ( image, "bzImage %p too short for kernel header\n",
|
||||||
|
image );
|
||||||
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read in header structures */
|
||||||
|
memset ( bzimg, 0, sizeof ( *bzimg ) );
|
||||||
|
copy_from_user ( &bzimg->cmdline_magic, src, BZI_CMDLINE_OFFSET,
|
||||||
|
sizeof ( bzimg->cmdline_magic ) );
|
||||||
|
copy_from_user ( &bzimg->bzhdr, src, BZI_HDR_OFFSET,
|
||||||
|
sizeof ( bzimg->bzhdr ) );
|
||||||
|
|
||||||
|
/* Calculate size of real-mode portion */
|
||||||
|
bzimg->rm_filesz =
|
||||||
|
( ( bzimg->bzhdr.setup_sects ? bzimg->bzhdr.setup_sects : 4 ) + 1 ) << 9;
|
||||||
|
if ( bzimg->rm_filesz > image->len ) {
|
||||||
|
DBGC ( image, "bzImage %p too short for %zd byte of setup\n",
|
||||||
|
image, bzimg->rm_filesz );
|
||||||
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
bzimg->rm_memsz = BZI_ASSUMED_RM_SIZE;
|
||||||
|
|
||||||
|
/* Calculate size of protected-mode portion */
|
||||||
|
bzimg->pm_sz = ( image->len - bzimg->rm_filesz );
|
||||||
|
syssize = ( ( bzimg->pm_sz + 15 ) / 16 );
|
||||||
|
|
||||||
|
/* Check for signatures and determine version */
|
||||||
|
if ( bzimg->bzhdr.boot_flag != BZI_BOOT_FLAG ) {
|
||||||
|
DBGC ( image, "bzImage %p missing 55AA signature\n", image );
|
||||||
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
if ( bzimg->bzhdr.header == BZI_SIGNATURE ) {
|
||||||
|
/* 2.00+ */
|
||||||
|
bzimg->version = bzimg->bzhdr.version;
|
||||||
|
} else {
|
||||||
|
/* Pre-2.00. Check that the syssize field is correct,
|
||||||
|
* as a guard against accepting arbitrary binary data,
|
||||||
|
* since the 55AA check is pretty lax. Note that the
|
||||||
|
* syssize field is unreliable for protocols between
|
||||||
|
* 2.00 and 2.03 inclusive, so we should not always
|
||||||
|
* check this field.
|
||||||
|
*/
|
||||||
|
bzimg->version = 0x0100;
|
||||||
|
if ( bzimg->bzhdr.syssize != syssize ) {
|
||||||
|
DBGC ( image, "bzImage %p bad syssize %x (expected "
|
||||||
|
"%x)\n", image, bzimg->bzhdr.syssize, syssize );
|
||||||
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine image type */
|
||||||
|
is_bzimage = ( ( bzimg->version >= 0x0200 ) ?
|
||||||
|
( bzimg->bzhdr.loadflags & BZI_LOAD_HIGH ) : 0 );
|
||||||
|
|
||||||
|
/* Calculate load address of real-mode portion */
|
||||||
|
bzimg->rm_kernel_seg = ( is_bzimage ? 0x1000 : 0x9000 );
|
||||||
|
bzimg->rm_kernel = real_to_user ( bzimg->rm_kernel_seg, 0 );
|
||||||
|
|
||||||
|
/* Allow space for the stack and heap */
|
||||||
|
bzimg->rm_memsz += BZI_STACK_SIZE;
|
||||||
|
bzimg->rm_heap = bzimg->rm_memsz;
|
||||||
|
|
||||||
|
/* Allow space for the command line */
|
||||||
|
bzimg->rm_cmdline = bzimg->rm_memsz;
|
||||||
|
bzimg->rm_memsz += BZI_CMDLINE_SIZE;
|
||||||
|
|
||||||
|
/* Calculate load address of protected-mode portion */
|
||||||
|
bzimg->pm_kernel = phys_to_user ( is_bzimage ? BZI_LOAD_HIGH_ADDR
|
||||||
|
: BZI_LOAD_LOW_ADDR );
|
||||||
|
|
||||||
|
/* Extract video mode */
|
||||||
|
bzimg->vid_mode = bzimg->bzhdr.vid_mode;
|
||||||
|
|
||||||
|
/* Extract memory limit */
|
||||||
|
bzimg->mem_limit = ( ( bzimg->version >= 0x0203 ) ?
|
||||||
|
bzimg->bzhdr.initrd_addr_max : BZI_INITRD_MAX );
|
||||||
|
|
||||||
|
/* Extract command line size */
|
||||||
|
bzimg->cmdline_size = ( ( bzimg->version >= 0x0206 ) ?
|
||||||
|
bzimg->bzhdr.cmdline_size : BZI_CMDLINE_SIZE );
|
||||||
|
|
||||||
|
DBGC ( image, "bzImage %p version %04x RM %#lx+%#zx PM %#lx+%#zx "
|
||||||
|
"cmdlen %zd\n", image, bzimg->version,
|
||||||
|
user_to_phys ( bzimg->rm_kernel, 0 ), bzimg->rm_filesz,
|
||||||
|
user_to_phys ( bzimg->pm_kernel, 0 ), bzimg->pm_sz,
|
||||||
|
bzimg->cmdline_size );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update bzImage header in loaded kernel
|
||||||
|
*
|
||||||
|
* @v image bzImage file
|
||||||
|
* @v bzimg bzImage context
|
||||||
|
* @v dst bzImage to update
|
||||||
|
*/
|
||||||
|
static void bzimage_update_header ( struct image *image,
|
||||||
|
struct bzimage_context *bzimg,
|
||||||
|
userptr_t dst ) {
|
||||||
|
|
||||||
|
/* Set loader type */
|
||||||
|
if ( bzimg->version >= 0x0200 )
|
||||||
|
bzimg->bzhdr.type_of_loader = BZI_LOADER_TYPE_GPXE;
|
||||||
|
|
||||||
|
/* Set heap end pointer */
|
||||||
|
if ( bzimg->version >= 0x0201 ) {
|
||||||
|
bzimg->bzhdr.heap_end_ptr = ( bzimg->rm_heap - 0x200 );
|
||||||
|
bzimg->bzhdr.loadflags |= BZI_CAN_USE_HEAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set command line */
|
||||||
|
if ( bzimg->version >= 0x0202 ) {
|
||||||
|
bzimg->bzhdr.cmd_line_ptr = user_to_phys ( bzimg->rm_kernel,
|
||||||
|
bzimg->rm_cmdline );
|
||||||
|
} else {
|
||||||
|
bzimg->cmdline_magic.magic = BZI_CMDLINE_MAGIC;
|
||||||
|
bzimg->cmdline_magic.offset = bzimg->rm_cmdline;
|
||||||
|
bzimg->bzhdr.setup_move_size = bzimg->rm_memsz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set video mode */
|
||||||
|
bzimg->bzhdr.vid_mode = bzimg->vid_mode;
|
||||||
|
|
||||||
|
/* Set initrd address */
|
||||||
|
if ( bzimg->version >= 0x0200 ) {
|
||||||
|
bzimg->bzhdr.ramdisk_image = bzimg->ramdisk_image;
|
||||||
|
bzimg->bzhdr.ramdisk_size = bzimg->ramdisk_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write out header structures */
|
||||||
|
copy_to_user ( dst, BZI_CMDLINE_OFFSET, &bzimg->cmdline_magic,
|
||||||
|
sizeof ( bzimg->cmdline_magic ) );
|
||||||
|
copy_to_user ( dst, BZI_HDR_OFFSET, &bzimg->bzhdr,
|
||||||
|
sizeof ( bzimg->bzhdr ) );
|
||||||
|
|
||||||
|
DBGC ( image, "bzImage %p vidmode %d\n", image, bzimg->vid_mode );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse kernel command line for bootloader parameters
|
* Parse kernel command line for bootloader parameters
|
||||||
*
|
*
|
||||||
* @v image bzImage file
|
* @v image bzImage file
|
||||||
* @v exec_ctx Execution context
|
* @v bzimg bzImage context
|
||||||
* @v cmdline Kernel command line
|
* @v cmdline Kernel command line
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int bzimage_parse_cmdline ( struct image *image,
|
static int bzimage_parse_cmdline ( struct image *image,
|
||||||
struct bzimage_exec_context *exec_ctx,
|
struct bzimage_context *bzimg,
|
||||||
const char *cmdline ) {
|
const char *cmdline ) {
|
||||||
char *vga;
|
char *vga;
|
||||||
char *mem;
|
char *mem;
|
||||||
@@ -105,13 +255,13 @@ static int bzimage_parse_cmdline ( struct image *image,
|
|||||||
if ( ( vga = strstr ( cmdline, "vga=" ) ) ) {
|
if ( ( vga = strstr ( cmdline, "vga=" ) ) ) {
|
||||||
vga += 4;
|
vga += 4;
|
||||||
if ( strcmp ( vga, "normal" ) == 0 ) {
|
if ( strcmp ( vga, "normal" ) == 0 ) {
|
||||||
exec_ctx->vid_mode = BZI_VID_MODE_NORMAL;
|
bzimg->vid_mode = BZI_VID_MODE_NORMAL;
|
||||||
} else if ( strcmp ( vga, "ext" ) == 0 ) {
|
} else if ( strcmp ( vga, "ext" ) == 0 ) {
|
||||||
exec_ctx->vid_mode = BZI_VID_MODE_EXT;
|
bzimg->vid_mode = BZI_VID_MODE_EXT;
|
||||||
} else if ( strcmp ( vga, "ask" ) == 0 ) {
|
} else if ( strcmp ( vga, "ask" ) == 0 ) {
|
||||||
exec_ctx->vid_mode = BZI_VID_MODE_ASK;
|
bzimg->vid_mode = BZI_VID_MODE_ASK;
|
||||||
} else {
|
} else {
|
||||||
exec_ctx->vid_mode = strtoul ( vga, &vga, 0 );
|
bzimg->vid_mode = strtoul ( vga, &vga, 0 );
|
||||||
if ( *vga && ( *vga != ' ' ) ) {
|
if ( *vga && ( *vga != ' ' ) ) {
|
||||||
DBGC ( image, "bzImage %p strange \"vga=\""
|
DBGC ( image, "bzImage %p strange \"vga=\""
|
||||||
"terminator '%c'\n", image, *vga );
|
"terminator '%c'\n", image, *vga );
|
||||||
@@ -122,17 +272,17 @@ static int bzimage_parse_cmdline ( struct image *image,
|
|||||||
/* Look for "mem=" */
|
/* Look for "mem=" */
|
||||||
if ( ( mem = strstr ( cmdline, "mem=" ) ) ) {
|
if ( ( mem = strstr ( cmdline, "mem=" ) ) ) {
|
||||||
mem += 4;
|
mem += 4;
|
||||||
exec_ctx->mem_limit = strtoul ( mem, &mem, 0 );
|
bzimg->mem_limit = strtoul ( mem, &mem, 0 );
|
||||||
switch ( *mem ) {
|
switch ( *mem ) {
|
||||||
case 'G':
|
case 'G':
|
||||||
case 'g':
|
case 'g':
|
||||||
exec_ctx->mem_limit <<= 10;
|
bzimg->mem_limit <<= 10;
|
||||||
case 'M':
|
case 'M':
|
||||||
case 'm':
|
case 'm':
|
||||||
exec_ctx->mem_limit <<= 10;
|
bzimg->mem_limit <<= 10;
|
||||||
case 'K':
|
case 'K':
|
||||||
case 'k':
|
case 'k':
|
||||||
exec_ctx->mem_limit <<= 10;
|
bzimg->mem_limit <<= 10;
|
||||||
break;
|
break;
|
||||||
case '\0':
|
case '\0':
|
||||||
case ' ':
|
case ' ':
|
||||||
@@ -142,7 +292,7 @@ static int bzimage_parse_cmdline ( struct image *image,
|
|||||||
"terminator '%c'\n", image, *mem );
|
"terminator '%c'\n", image, *mem );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
exec_ctx->mem_limit -= 1;
|
bzimg->mem_limit -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -152,20 +302,20 @@ static int bzimage_parse_cmdline ( struct image *image,
|
|||||||
* Set command line
|
* Set command line
|
||||||
*
|
*
|
||||||
* @v image bzImage image
|
* @v image bzImage image
|
||||||
* @v exec_ctx Execution context
|
* @v bzimg bzImage context
|
||||||
* @v cmdline Kernel command line
|
* @v cmdline Kernel command line
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int bzimage_set_cmdline ( struct image *image,
|
static int bzimage_set_cmdline ( struct image *image,
|
||||||
struct bzimage_exec_context *exec_ctx,
|
struct bzimage_context *bzimg,
|
||||||
const char *cmdline ) {
|
const char *cmdline ) {
|
||||||
size_t cmdline_len;
|
size_t cmdline_len;
|
||||||
|
|
||||||
/* Copy command line down to real-mode portion */
|
/* Copy command line down to real-mode portion */
|
||||||
cmdline_len = ( strlen ( cmdline ) + 1 );
|
cmdline_len = ( strlen ( cmdline ) + 1 );
|
||||||
if ( cmdline_len > exec_ctx->cmdline_size )
|
if ( cmdline_len > bzimg->cmdline_size )
|
||||||
cmdline_len = exec_ctx->cmdline_size;
|
cmdline_len = bzimg->cmdline_size;
|
||||||
copy_to_user ( exec_ctx->rm_kernel, exec_ctx->rm_cmdline,
|
copy_to_user ( bzimg->rm_kernel, bzimg->rm_cmdline,
|
||||||
cmdline, cmdline_len );
|
cmdline, cmdline_len );
|
||||||
DBGC ( image, "bzImage %p command line \"%s\"\n", image, cmdline );
|
DBGC ( image, "bzImage %p command line \"%s\"\n", image, cmdline );
|
||||||
|
|
||||||
@@ -217,14 +367,16 @@ static size_t bzimage_load_initrd ( struct image *image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy in initrd image body */
|
/* Copy in initrd image body */
|
||||||
|
if ( address )
|
||||||
|
memcpy_user ( address, offset, initrd->data, 0, initrd->len );
|
||||||
|
offset += initrd->len;
|
||||||
if ( address ) {
|
if ( address ) {
|
||||||
DBGC ( image, "bzImage %p has initrd %p at [%lx,%lx)\n",
|
DBGC ( image, "bzImage %p has initrd %p at [%lx,%lx)\n",
|
||||||
image, initrd, address, ( address + offset ) );
|
image, initrd, user_to_phys ( address, 0 ),
|
||||||
memcpy_user ( address, offset, initrd->data, 0,
|
user_to_phys ( address, offset ) );
|
||||||
initrd->len );
|
|
||||||
}
|
}
|
||||||
offset += initrd->len;
|
|
||||||
|
|
||||||
|
/* Round up to 4-byte boundary */
|
||||||
offset = ( ( offset + 0x03 ) & ~0x03 );
|
offset = ( ( offset + 0x03 ) & ~0x03 );
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
@@ -233,20 +385,19 @@ static size_t bzimage_load_initrd ( struct image *image,
|
|||||||
* Load initrds, if any
|
* Load initrds, if any
|
||||||
*
|
*
|
||||||
* @v image bzImage image
|
* @v image bzImage image
|
||||||
* @v exec_ctx Execution context
|
* @v bzimg bzImage context
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int bzimage_load_initrds ( struct image *image,
|
static int bzimage_load_initrds ( struct image *image,
|
||||||
struct bzimage_exec_context *exec_ctx ) {
|
struct bzimage_context *bzimg ) {
|
||||||
struct image *initrd;
|
struct image *initrd;
|
||||||
size_t total_len = 0;
|
size_t total_len = 0;
|
||||||
physaddr_t address;
|
physaddr_t address;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Add up length of all initrd images */
|
/* Add up length of all initrd images */
|
||||||
for_each_image ( initrd ) {
|
for_each_image ( initrd )
|
||||||
total_len += bzimage_load_initrd ( image, initrd, UNULL );
|
total_len += bzimage_load_initrd ( image, initrd, UNULL );
|
||||||
}
|
|
||||||
|
|
||||||
/* Give up if no initrd images found */
|
/* Give up if no initrd images found */
|
||||||
if ( ! total_len )
|
if ( ! total_len )
|
||||||
@@ -268,7 +419,7 @@ static int bzimage_load_initrds ( struct image *image,
|
|||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
/* Check that we are within the kernel's range */
|
/* Check that we are within the kernel's range */
|
||||||
if ( ( address + total_len - 1 ) > exec_ctx->mem_limit )
|
if ( ( address + total_len - 1 ) > bzimg->mem_limit )
|
||||||
continue;
|
continue;
|
||||||
/* Prepare and verify segment */
|
/* Prepare and verify segment */
|
||||||
if ( ( rc = prep_segment ( phys_to_user ( address ), 0,
|
if ( ( rc = prep_segment ( phys_to_user ( address ), 0,
|
||||||
@@ -279,8 +430,8 @@ static int bzimage_load_initrds ( struct image *image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Record initrd location */
|
/* Record initrd location */
|
||||||
exec_ctx->ramdisk_image = address;
|
bzimg->ramdisk_image = address;
|
||||||
exec_ctx->ramdisk_size = total_len;
|
bzimg->ramdisk_size = total_len;
|
||||||
|
|
||||||
/* Construct initrd */
|
/* Construct initrd */
|
||||||
DBGC ( image, "bzImage %p constructing initrd at [%lx,%lx)\n",
|
DBGC ( image, "bzImage %p constructing initrd at [%lx,%lx)\n",
|
||||||
@@ -300,60 +451,37 @@ static int bzimage_load_initrds ( struct image *image,
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int bzimage_exec ( struct image *image ) {
|
static int bzimage_exec ( struct image *image ) {
|
||||||
struct bzimage_exec_context exec_ctx;
|
struct bzimage_context bzimg;
|
||||||
struct bzimage_header bzhdr;
|
|
||||||
const char *cmdline = ( image->cmdline ? image->cmdline : "" );
|
const char *cmdline = ( image->cmdline ? image->cmdline : "" );
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Initialise context */
|
/* Read and parse header from loaded kernel */
|
||||||
memset ( &exec_ctx, 0, sizeof ( exec_ctx ) );
|
if ( ( rc = bzimage_parse_header ( image, &bzimg,
|
||||||
|
image->priv.user ) ) != 0 )
|
||||||
/* Retrieve kernel header */
|
return rc;
|
||||||
exec_ctx.rm_kernel_seg = image->priv.ul;
|
assert ( bzimg.rm_kernel == image->priv.user );
|
||||||
exec_ctx.rm_kernel = real_to_user ( exec_ctx.rm_kernel_seg, 0 );
|
|
||||||
copy_from_user ( &bzhdr, exec_ctx.rm_kernel, BZI_HDR_OFFSET,
|
|
||||||
sizeof ( bzhdr ) );
|
|
||||||
exec_ctx.rm_cmdline = exec_ctx.rm_heap =
|
|
||||||
( bzhdr.heap_end_ptr + 0x200 );
|
|
||||||
exec_ctx.vid_mode = bzhdr.vid_mode;
|
|
||||||
if ( bzhdr.version >= 0x0203 ) {
|
|
||||||
exec_ctx.mem_limit = bzhdr.initrd_addr_max;
|
|
||||||
} else {
|
|
||||||
exec_ctx.mem_limit = BZI_INITRD_MAX;
|
|
||||||
}
|
|
||||||
if ( bzhdr.version >= 0x0206 ) {
|
|
||||||
exec_ctx.cmdline_size = bzhdr.cmdline_size;
|
|
||||||
} else {
|
|
||||||
exec_ctx.cmdline_size = BZI_CMDLINE_SIZE;
|
|
||||||
}
|
|
||||||
DBG ( "cmdline_size = %zd\n", exec_ctx.cmdline_size );
|
|
||||||
|
|
||||||
/* Parse command line for bootloader parameters */
|
/* Parse command line for bootloader parameters */
|
||||||
if ( ( rc = bzimage_parse_cmdline ( image, &exec_ctx, cmdline ) ) != 0)
|
if ( ( rc = bzimage_parse_cmdline ( image, &bzimg, cmdline ) ) != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Store command line */
|
/* Store command line */
|
||||||
if ( ( rc = bzimage_set_cmdline ( image, &exec_ctx, cmdline ) ) != 0 )
|
if ( ( rc = bzimage_set_cmdline ( image, &bzimg, cmdline ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Load any initrds */
|
/* Load any initrds */
|
||||||
if ( ( rc = bzimage_load_initrds ( image, &exec_ctx ) ) != 0 )
|
if ( ( rc = bzimage_load_initrds ( image, &bzimg ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Update and store kernel header */
|
/* Update kernel header */
|
||||||
bzhdr.vid_mode = exec_ctx.vid_mode;
|
bzimage_update_header ( image, &bzimg, bzimg.rm_kernel );
|
||||||
bzhdr.ramdisk_image = exec_ctx.ramdisk_image;
|
|
||||||
bzhdr.ramdisk_size = exec_ctx.ramdisk_size;
|
|
||||||
copy_to_user ( exec_ctx.rm_kernel, BZI_HDR_OFFSET, &bzhdr,
|
|
||||||
sizeof ( bzhdr ) );
|
|
||||||
|
|
||||||
/* Prepare for exiting */
|
/* Prepare for exiting */
|
||||||
shutdown ( SHUTDOWN_BOOT );
|
shutdown ( SHUTDOWN_BOOT );
|
||||||
|
|
||||||
DBGC ( image, "bzImage %p jumping to RM kernel at %04x:0000 "
|
DBGC ( image, "bzImage %p jumping to RM kernel at %04x:0000 "
|
||||||
"(stack %04x:%04zx)\n", image,
|
"(stack %04x:%04zx)\n", image, ( bzimg.rm_kernel_seg + 0x20 ),
|
||||||
( exec_ctx.rm_kernel_seg + 0x20 ),
|
bzimg.rm_kernel_seg, bzimg.rm_heap );
|
||||||
exec_ctx.rm_kernel_seg, exec_ctx.rm_heap );
|
|
||||||
|
|
||||||
/* Jump to the kernel */
|
/* Jump to the kernel */
|
||||||
__asm__ __volatile__ ( REAL_CODE ( "movw %w0, %%ds\n\t"
|
__asm__ __volatile__ ( REAL_CODE ( "movw %w0, %%ds\n\t"
|
||||||
@@ -365,9 +493,9 @@ static int bzimage_exec ( struct image *image ) {
|
|||||||
"pushw %w2\n\t"
|
"pushw %w2\n\t"
|
||||||
"pushw $0\n\t"
|
"pushw $0\n\t"
|
||||||
"lret\n\t" )
|
"lret\n\t" )
|
||||||
: : "r" ( exec_ctx.rm_kernel_seg ),
|
: : "r" ( bzimg.rm_kernel_seg ),
|
||||||
"r" ( exec_ctx.rm_heap ),
|
"r" ( bzimg.rm_heap ),
|
||||||
"r" ( exec_ctx.rm_kernel_seg + 0x20 ) );
|
"r" ( bzimg.rm_kernel_seg + 0x20 ) );
|
||||||
|
|
||||||
/* There is no way for the image to return, since we provide
|
/* There is no way for the image to return, since we provide
|
||||||
* no return address.
|
* no return address.
|
||||||
@@ -377,157 +505,6 @@ static int bzimage_exec ( struct image *image ) {
|
|||||||
return -ECANCELED; /* -EIMPOSSIBLE */
|
return -ECANCELED; /* -EIMPOSSIBLE */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load and parse bzImage header
|
|
||||||
*
|
|
||||||
* @v image bzImage file
|
|
||||||
* @v load_ctx Load context
|
|
||||||
* @v bzhdr Buffer for bzImage header
|
|
||||||
* @ret rc Return status code
|
|
||||||
*/
|
|
||||||
static int bzimage_load_header ( struct image *image,
|
|
||||||
struct bzimage_load_context *load_ctx,
|
|
||||||
struct bzimage_header *bzhdr ) {
|
|
||||||
|
|
||||||
/* Sanity check */
|
|
||||||
if ( image->len < ( BZI_HDR_OFFSET + sizeof ( *bzhdr ) ) ) {
|
|
||||||
DBGC ( image, "bzImage %p too short for kernel header\n",
|
|
||||||
image );
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read and verify header */
|
|
||||||
copy_from_user ( bzhdr, image->data, BZI_HDR_OFFSET,
|
|
||||||
sizeof ( *bzhdr ) );
|
|
||||||
if ( bzhdr->header != BZI_SIGNATURE ) {
|
|
||||||
DBGC ( image, "bzImage %p bad signature %08lx\n",
|
|
||||||
image, bzhdr->header );
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We don't support ancient kernels */
|
|
||||||
if ( bzhdr->version < 0x0200 ) {
|
|
||||||
DBGC ( image, "bzImage %p version %04x not supported\n",
|
|
||||||
image, bzhdr->version );
|
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculate load address and size of real-mode portion */
|
|
||||||
load_ctx->rm_kernel_seg = ( ( bzhdr->loadflags & BZI_LOAD_HIGH ) ?
|
|
||||||
0x1000 : /* 1000:0000 (bzImage) */
|
|
||||||
0x9000 ); /* 9000:0000 (zImage) */
|
|
||||||
load_ctx->rm_kernel = real_to_user ( load_ctx->rm_kernel_seg, 0 );
|
|
||||||
load_ctx->rm_filesz =
|
|
||||||
( ( bzhdr->setup_sects ? bzhdr->setup_sects : 4 ) + 1 ) << 9;
|
|
||||||
load_ctx->rm_memsz = BZI_ASSUMED_RM_SIZE;
|
|
||||||
if ( load_ctx->rm_filesz > image->len ) {
|
|
||||||
DBGC ( image, "bzImage %p too short for %zd byte of setup\n",
|
|
||||||
image, load_ctx->rm_filesz );
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculate load address and size of non-real-mode portion */
|
|
||||||
load_ctx->pm_kernel = ( ( bzhdr->loadflags & BZI_LOAD_HIGH ) ?
|
|
||||||
phys_to_user ( BZI_LOAD_HIGH_ADDR ) :
|
|
||||||
phys_to_user ( BZI_LOAD_LOW_ADDR ) );
|
|
||||||
load_ctx->pm_sz = ( image->len - load_ctx->rm_filesz );
|
|
||||||
|
|
||||||
DBGC ( image, "bzImage %p version %04x RM %#zx bytes PM %#zx bytes\n",
|
|
||||||
image, bzhdr->version, load_ctx->rm_filesz, load_ctx->pm_sz );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load real-mode portion of bzImage
|
|
||||||
*
|
|
||||||
* @v image bzImage file
|
|
||||||
* @v load_ctx Load context
|
|
||||||
* @ret rc Return status code
|
|
||||||
*/
|
|
||||||
static int bzimage_load_real ( struct image *image,
|
|
||||||
struct bzimage_load_context *load_ctx ) {
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
/* Allow space for the stack and heap */
|
|
||||||
load_ctx->rm_memsz += BZI_STACK_SIZE;
|
|
||||||
load_ctx->rm_heap = load_ctx->rm_memsz;
|
|
||||||
|
|
||||||
/* Allow space for the command line */
|
|
||||||
load_ctx->rm_cmdline = load_ctx->rm_memsz;
|
|
||||||
load_ctx->rm_memsz += BZI_CMDLINE_SIZE;
|
|
||||||
|
|
||||||
/* Prepare, verify, and load the real-mode segment */
|
|
||||||
if ( ( rc = prep_segment ( load_ctx->rm_kernel, load_ctx->rm_filesz,
|
|
||||||
load_ctx->rm_memsz ) ) != 0 ) {
|
|
||||||
DBGC ( image, "bzImage %p could not prepare RM segment: %s\n",
|
|
||||||
image, strerror ( rc ) );
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
memcpy_user ( load_ctx->rm_kernel, 0, image->data, 0,
|
|
||||||
load_ctx->rm_filesz );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load non-real-mode portion of bzImage
|
|
||||||
*
|
|
||||||
* @v image bzImage file
|
|
||||||
* @v load_ctx Load context
|
|
||||||
* @ret rc Return status code
|
|
||||||
*/
|
|
||||||
static int bzimage_load_non_real ( struct image *image,
|
|
||||||
struct bzimage_load_context *load_ctx ) {
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
/* Prepare, verify and load the non-real-mode segment */
|
|
||||||
if ( ( rc = prep_segment ( load_ctx->pm_kernel, load_ctx->pm_sz,
|
|
||||||
load_ctx->pm_sz ) ) != 0 ) {
|
|
||||||
DBGC ( image, "bzImage %p could not prepare PM segment: %s\n",
|
|
||||||
image, strerror ( rc ) );
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
memcpy_user ( load_ctx->pm_kernel, 0, image->data, load_ctx->rm_filesz,
|
|
||||||
load_ctx->pm_sz );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update and store bzImage header
|
|
||||||
*
|
|
||||||
* @v image bzImage file
|
|
||||||
* @v load_ctx Load context
|
|
||||||
* @v bzhdr Original bzImage header
|
|
||||||
* @ret rc Return status code
|
|
||||||
*/
|
|
||||||
static int bzimage_write_header ( struct image *image __unused,
|
|
||||||
struct bzimage_load_context *load_ctx,
|
|
||||||
struct bzimage_header *bzhdr ) {
|
|
||||||
struct bzimage_cmdline cmdline;
|
|
||||||
|
|
||||||
/* Update the header and copy it into the loaded kernel */
|
|
||||||
bzhdr->type_of_loader = BZI_LOADER_TYPE_GPXE;
|
|
||||||
if ( bzhdr->version >= 0x0201 ) {
|
|
||||||
bzhdr->heap_end_ptr = ( load_ctx->rm_heap - 0x200 );
|
|
||||||
bzhdr->loadflags |= BZI_CAN_USE_HEAP;
|
|
||||||
}
|
|
||||||
if ( bzhdr->version >= 0x0202 ) {
|
|
||||||
bzhdr->cmd_line_ptr = user_to_phys ( load_ctx->rm_kernel,
|
|
||||||
load_ctx->rm_cmdline );
|
|
||||||
} else {
|
|
||||||
cmdline.magic = BZI_CMDLINE_MAGIC;
|
|
||||||
cmdline.offset = load_ctx->rm_cmdline;
|
|
||||||
copy_to_user ( load_ctx->rm_kernel, BZI_CMDLINE_OFFSET,
|
|
||||||
&cmdline, sizeof ( cmdline ) );
|
|
||||||
bzhdr->setup_move_size = load_ctx->rm_memsz;
|
|
||||||
}
|
|
||||||
copy_to_user ( load_ctx->rm_kernel, BZI_HDR_OFFSET,
|
|
||||||
bzhdr, sizeof ( *bzhdr ) );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load bzImage image into memory
|
* Load bzImage image into memory
|
||||||
*
|
*
|
||||||
@@ -535,35 +512,43 @@ static int bzimage_write_header ( struct image *image __unused,
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int bzimage_load ( struct image *image ) {
|
int bzimage_load ( struct image *image ) {
|
||||||
struct bzimage_load_context load_ctx;
|
struct bzimage_context bzimg;
|
||||||
struct bzimage_header bzhdr;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Initialise context */
|
/* Read and parse header from image */
|
||||||
memset ( &load_ctx, 0, sizeof ( load_ctx ) );
|
if ( ( rc = bzimage_parse_header ( image, &bzimg,
|
||||||
|
image->data ) ) != 0 )
|
||||||
/* Load and verify header */
|
|
||||||
if ( ( rc = bzimage_load_header ( image, &load_ctx, &bzhdr ) ) != 0 )
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* This is a bzImage image, valid or otherwise */
|
/* This is a bzImage image, valid or otherwise */
|
||||||
if ( ! image->type )
|
if ( ! image->type )
|
||||||
image->type = &bzimage_image_type;
|
image->type = &bzimage_image_type;
|
||||||
|
|
||||||
/* Load real-mode portion */
|
/* Prepare segments */
|
||||||
if ( ( rc = bzimage_load_real ( image, &load_ctx ) ) != 0 )
|
if ( ( rc = prep_segment ( bzimg.rm_kernel, bzimg.rm_filesz,
|
||||||
|
bzimg.rm_memsz ) ) != 0 ) {
|
||||||
|
DBGC ( image, "bzImage %p could not prepare RM segment: %s\n",
|
||||||
|
image, strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
|
if ( ( rc = prep_segment ( bzimg.pm_kernel, bzimg.pm_sz,
|
||||||
|
bzimg.pm_sz ) ) != 0 ) {
|
||||||
|
DBGC ( image, "bzImage %p could not prepare PM segment: %s\n",
|
||||||
|
image, strerror ( rc ) );
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/* Load non-real-mode portion */
|
/* Load segments */
|
||||||
if ( ( rc = bzimage_load_non_real ( image, &load_ctx ) ) != 0 )
|
memcpy_user ( bzimg.rm_kernel, 0, image->data,
|
||||||
return rc;
|
0, bzimg.rm_filesz );
|
||||||
|
memcpy_user ( bzimg.pm_kernel, 0, image->data,
|
||||||
|
bzimg.rm_filesz, bzimg.pm_sz );
|
||||||
|
|
||||||
/* Update and write out header */
|
/* Update and write out header */
|
||||||
if ( ( rc = bzimage_write_header ( image, &load_ctx, &bzhdr ) ) != 0 )
|
bzimage_update_header ( image, &bzimg, bzimg.rm_kernel );
|
||||||
return rc;
|
|
||||||
|
|
||||||
/* Record real-mode segment in image private data field */
|
/* Record real-mode segment in image private data field */
|
||||||
image->priv.ul = load_ctx.rm_kernel_seg;
|
image->priv.user = bzimg.rm_kernel;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-18
@@ -23,6 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -52,7 +54,7 @@ static int com32_exec ( struct image *image ) {
|
|||||||
int state;
|
int state;
|
||||||
uint32_t avail_mem_top;
|
uint32_t avail_mem_top;
|
||||||
|
|
||||||
state = setjmp ( comboot_return );
|
state = rmsetjmp ( comboot_return );
|
||||||
|
|
||||||
switch ( state ) {
|
switch ( state ) {
|
||||||
case 0: /* First time through; invoke COM32 program */
|
case 0: /* First time through; invoke COM32 program */
|
||||||
@@ -70,20 +72,20 @@ static int com32_exec ( struct image *image ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBGC ( image, "COM32 %p: available memory top = 0x%x\n",
|
DBGC ( image, "COM32 %p: available memory top = 0x%x\n",
|
||||||
image, (int)avail_mem_top );
|
image, avail_mem_top );
|
||||||
|
|
||||||
assert ( avail_mem_top != 0 );
|
assert ( avail_mem_top != 0 );
|
||||||
|
|
||||||
com32_external_esp = phys_to_virt ( avail_mem_top );
|
com32_external_esp = phys_to_virt ( avail_mem_top );
|
||||||
|
|
||||||
/* Hook COMBOOT API interrupts */
|
/* Hook COMBOOT API interrupts */
|
||||||
hook_comboot_interrupts( );
|
hook_comboot_interrupts();
|
||||||
|
|
||||||
/* Temporarily de-register image, so that a "boot" command
|
/* Unregister image, so that a "boot" command doesn't
|
||||||
* doesn't throw us into an execution loop. Hold a reference
|
* throw us into an execution loop. We never
|
||||||
* to avoid the image's being freed.
|
* reregister ourselves; COMBOOT images expect to be
|
||||||
|
* removed on exit.
|
||||||
*/
|
*/
|
||||||
image_get ( image );
|
|
||||||
unregister_image ( image );
|
unregister_image ( image );
|
||||||
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
@@ -111,25 +113,33 @@ static int com32_exec ( struct image *image ) {
|
|||||||
/* %6 */ "r" ( COM32_START_PHYS )
|
/* %6 */ "r" ( COM32_START_PHYS )
|
||||||
:
|
:
|
||||||
"memory" );
|
"memory" );
|
||||||
|
DBGC ( image, "COM32 %p: returned\n", image );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMBOOT_RETURN_RUN_KERNEL:
|
case COMBOOT_EXIT:
|
||||||
DBGC ( image, "COM32 %p: returned to run kernel...\n", image );
|
DBGC ( image, "COM32 %p: exited\n", image );
|
||||||
comboot_run_kernel ( );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMBOOT_RETURN_EXIT:
|
case COMBOOT_EXIT_RUN_KERNEL:
|
||||||
|
DBGC ( image, "COM32 %p: exited to run kernel %p\n",
|
||||||
|
image, comboot_replacement_image );
|
||||||
|
image->replacement = comboot_replacement_image;
|
||||||
|
comboot_replacement_image = NULL;
|
||||||
|
image_autoload ( image->replacement );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case COMBOOT_EXIT_COMMAND:
|
||||||
|
DBGC ( image, "COM32 %p: exited after executing command\n",
|
||||||
|
image );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert ( 0 );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
comboot_force_text_mode ( );
|
unhook_comboot_interrupts();
|
||||||
|
comboot_force_text_mode();
|
||||||
DBGC ( image, "COM32 %p returned\n", image );
|
|
||||||
|
|
||||||
/* Re-register image and return */
|
|
||||||
register_image ( image );
|
|
||||||
image_put ( image );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -133,7 +135,7 @@ static int comboot_exec ( struct image *image ) {
|
|||||||
userptr_t seg_userptr = real_to_user ( COMBOOT_PSP_SEG, 0 );
|
userptr_t seg_userptr = real_to_user ( COMBOOT_PSP_SEG, 0 );
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
state = setjmp ( comboot_return );
|
state = rmsetjmp ( comboot_return );
|
||||||
|
|
||||||
switch ( state ) {
|
switch ( state ) {
|
||||||
case 0: /* First time through; invoke COMBOOT program */
|
case 0: /* First time through; invoke COMBOOT program */
|
||||||
@@ -142,16 +144,16 @@ static int comboot_exec ( struct image *image ) {
|
|||||||
comboot_init_psp ( image, seg_userptr );
|
comboot_init_psp ( image, seg_userptr );
|
||||||
|
|
||||||
/* Hook COMBOOT API interrupts */
|
/* Hook COMBOOT API interrupts */
|
||||||
hook_comboot_interrupts ( );
|
hook_comboot_interrupts();
|
||||||
|
|
||||||
DBGC ( image, "executing 16-bit COMBOOT image at %4x:0100\n",
|
DBGC ( image, "executing 16-bit COMBOOT image at %4x:0100\n",
|
||||||
COMBOOT_PSP_SEG );
|
COMBOOT_PSP_SEG );
|
||||||
|
|
||||||
/* Temporarily de-register image, so that a "boot" command
|
/* Unregister image, so that a "boot" command doesn't
|
||||||
* doesn't throw us into an execution loop. Hold a reference
|
* throw us into an execution loop. We never
|
||||||
* to avoid the image's being freed.
|
* reregister ourselves; COMBOOT images expect to be
|
||||||
|
* removed on exit.
|
||||||
*/
|
*/
|
||||||
image_get ( image );
|
|
||||||
unregister_image ( image );
|
unregister_image ( image );
|
||||||
|
|
||||||
/* Store stack segment at 0x38 and stack pointer at 0x3A
|
/* Store stack segment at 0x38 and stack pointer at 0x3A
|
||||||
@@ -180,26 +182,34 @@ static int comboot_exec ( struct image *image ) {
|
|||||||
"xorw %%bp, %%bp\n\t"
|
"xorw %%bp, %%bp\n\t"
|
||||||
"lret\n\t" )
|
"lret\n\t" )
|
||||||
: : "r" ( COMBOOT_PSP_SEG ) : "eax" );
|
: : "r" ( COMBOOT_PSP_SEG ) : "eax" );
|
||||||
|
DBGC ( image, "COMBOOT %p: returned\n", image );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMBOOT_RETURN_RUN_KERNEL:
|
case COMBOOT_EXIT:
|
||||||
DBGC ( image, "COMBOOT %p: returned to run kernel...\n", image );
|
DBGC ( image, "COMBOOT %p: exited\n", image );
|
||||||
comboot_run_kernel ( );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMBOOT_RETURN_EXIT:
|
case COMBOOT_EXIT_RUN_KERNEL:
|
||||||
|
DBGC ( image, "COMBOOT %p: exited to run kernel %p\n",
|
||||||
|
image, comboot_replacement_image );
|
||||||
|
image->replacement = comboot_replacement_image;
|
||||||
|
comboot_replacement_image = NULL;
|
||||||
|
image_autoload ( image->replacement );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case COMBOOT_EXIT_COMMAND:
|
||||||
|
DBGC ( image, "COMBOOT %p: exited after executing command\n",
|
||||||
|
image );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert ( 0 );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
comboot_force_text_mode ( );
|
unhook_comboot_interrupts();
|
||||||
|
comboot_force_text_mode();
|
||||||
|
|
||||||
DBGC ( image, "COMBOOT %p returned\n", image );
|
|
||||||
|
|
||||||
/* Re-register image and return */
|
|
||||||
register_image ( image );
|
|
||||||
image_put ( image );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
#include <gpxe/image.h>
|
#include <gpxe/image.h>
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
*
|
*
|
||||||
@@ -139,10 +141,11 @@ static void multiboot_build_memmap ( struct image *image,
|
|||||||
/**
|
/**
|
||||||
* Add command line in base memory
|
* Add command line in base memory
|
||||||
*
|
*
|
||||||
|
* @v imgname Image name
|
||||||
* @v cmdline Command line
|
* @v cmdline Command line
|
||||||
* @ret physaddr Physical address of command line
|
* @ret physaddr Physical address of command line
|
||||||
*/
|
*/
|
||||||
physaddr_t multiboot_add_cmdline ( const char *cmdline ) {
|
physaddr_t multiboot_add_cmdline ( const char *imgname, const char *cmdline ) {
|
||||||
char *mb_cmdline;
|
char *mb_cmdline;
|
||||||
|
|
||||||
if ( ! cmdline )
|
if ( ! cmdline )
|
||||||
@@ -153,7 +156,7 @@ physaddr_t multiboot_add_cmdline ( const char *cmdline ) {
|
|||||||
mb_cmdline_offset +=
|
mb_cmdline_offset +=
|
||||||
( snprintf ( mb_cmdline,
|
( snprintf ( mb_cmdline,
|
||||||
( sizeof ( mb_cmdlines ) - mb_cmdline_offset ),
|
( sizeof ( mb_cmdlines ) - mb_cmdline_offset ),
|
||||||
"%s", cmdline ) + 1 );
|
"%s %s", imgname, cmdline ) + 1 );
|
||||||
|
|
||||||
/* Truncate to terminating NUL in buffer if necessary */
|
/* Truncate to terminating NUL in buffer if necessary */
|
||||||
if ( mb_cmdline_offset > sizeof ( mb_cmdlines ) )
|
if ( mb_cmdline_offset > sizeof ( mb_cmdlines ) )
|
||||||
@@ -208,8 +211,8 @@ multiboot_build_module_list ( struct image *image,
|
|||||||
( ( count - insert ) * sizeof ( *module ) ) );
|
( ( count - insert ) * sizeof ( *module ) ) );
|
||||||
module->mod_start = start;
|
module->mod_start = start;
|
||||||
module->mod_end = end;
|
module->mod_end = end;
|
||||||
module->string =
|
module->string = multiboot_add_cmdline ( module_image->name,
|
||||||
multiboot_add_cmdline ( module_image->cmdline );
|
module_image->cmdline );
|
||||||
module->reserved = 0;
|
module->reserved = 0;
|
||||||
|
|
||||||
/* We promise to page-align modules */
|
/* We promise to page-align modules */
|
||||||
@@ -220,7 +223,7 @@ multiboot_build_module_list ( struct image *image,
|
|||||||
|
|
||||||
/* Dump module configuration */
|
/* Dump module configuration */
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
DBGC ( image, "MULTIBOOT %p module %d is [%lx,%lx)\n",
|
DBGC ( image, "MULTIBOOT %p module %d is [%x,%x)\n",
|
||||||
image, i, modules[i].mod_start,
|
image, i, modules[i].mod_start,
|
||||||
modules[i].mod_end );
|
modules[i].mod_end );
|
||||||
}
|
}
|
||||||
@@ -267,7 +270,7 @@ static int multiboot_exec ( struct image *image ) {
|
|||||||
multiboot_build_memmap ( image, &mbinfo, mbmemmap,
|
multiboot_build_memmap ( image, &mbinfo, mbmemmap,
|
||||||
( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
|
( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
|
||||||
mb_cmdline_offset = 0;
|
mb_cmdline_offset = 0;
|
||||||
mbinfo.cmdline = multiboot_add_cmdline ( image->cmdline );
|
mbinfo.cmdline = multiboot_add_cmdline ( image->name, image->cmdline );
|
||||||
mbinfo.mods_count = multiboot_build_module_list ( image, mbmodules,
|
mbinfo.mods_count = multiboot_build_module_list ( image, mbmodules,
|
||||||
( sizeof(mbmodules) / sizeof(mbmodules[0]) ) );
|
( sizeof(mbmodules) / sizeof(mbmodules[0]) ) );
|
||||||
mbinfo.mods_addr = virt_to_phys ( mbmodules );
|
mbinfo.mods_addr = virt_to_phys ( mbmodules );
|
||||||
@@ -282,11 +285,13 @@ static int multiboot_exec ( struct image *image ) {
|
|||||||
/* Jump to OS with flat physical addressing */
|
/* Jump to OS with flat physical addressing */
|
||||||
DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
|
DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
|
||||||
image, entry );
|
image, entry );
|
||||||
__asm__ __volatile__ ( PHYS_CODE ( "call *%%edi\n\t" )
|
__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t"
|
||||||
|
"call *%%edi\n\t"
|
||||||
|
"popl %%ebp\n\t" )
|
||||||
: : "a" ( MULTIBOOT_BOOTLOADER_MAGIC ),
|
: : "a" ( MULTIBOOT_BOOTLOADER_MAGIC ),
|
||||||
"b" ( virt_to_phys ( &mbinfo ) ),
|
"b" ( virt_to_phys ( &mbinfo ) ),
|
||||||
"D" ( entry )
|
"D" ( entry )
|
||||||
: "ecx", "edx", "esi", "ebp", "memory" );
|
: "ecx", "edx", "esi", "memory" );
|
||||||
|
|
||||||
DBGC ( image, "MULTIBOOT %p returned\n", image );
|
DBGC ( image, "MULTIBOOT %p returned\n", image );
|
||||||
|
|
||||||
@@ -358,6 +363,13 @@ static int multiboot_load_raw ( struct image *image,
|
|||||||
userptr_t buffer;
|
userptr_t buffer;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
if ( ! ( hdr->mb.flags & MB_FLAG_RAW ) ) {
|
||||||
|
DBGC ( image, "MULTIBOOT %p is not flagged as a raw image\n",
|
||||||
|
image );
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Verify and prepare segment */
|
/* Verify and prepare segment */
|
||||||
offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
|
offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
|
||||||
filesz = ( hdr->mb.load_end_addr ?
|
filesz = ( hdr->mb.load_end_addr ?
|
||||||
@@ -416,7 +428,7 @@ static int multiboot_load ( struct image *image ) {
|
|||||||
image );
|
image );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
DBGC ( image, "MULTIBOOT %p found header with flags %08lx\n",
|
DBGC ( image, "MULTIBOOT %p found header with flags %08x\n",
|
||||||
image, hdr.mb.flags );
|
image, hdr.mb.flags );
|
||||||
|
|
||||||
/* This is a multiboot image, valid or otherwise */
|
/* This is a multiboot image, valid or otherwise */
|
||||||
@@ -425,19 +437,19 @@ static int multiboot_load ( struct image *image ) {
|
|||||||
|
|
||||||
/* Abort if we detect flags that we cannot support */
|
/* Abort if we detect flags that we cannot support */
|
||||||
if ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) {
|
if ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) {
|
||||||
DBGC ( image, "MULTIBOOT %p flags %08lx not supported\n",
|
DBGC ( image, "MULTIBOOT %p flags %08x not supported\n",
|
||||||
image, ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) );
|
image, ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) );
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load the actual image */
|
/* There is technically a bit MB_FLAG_RAW to indicate whether
|
||||||
if ( hdr.mb.flags & MB_FLAG_RAW ) {
|
* this is an ELF or a raw image. In practice, grub will use
|
||||||
if ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 )
|
* the ELF header if present, and Solaris relies on this
|
||||||
return rc;
|
* behaviour.
|
||||||
} else {
|
*/
|
||||||
if ( ( rc = multiboot_load_elf ( image ) ) != 0 )
|
if ( ( ( rc = multiboot_load_elf ( image ) ) != 0 ) &&
|
||||||
return rc;
|
( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 ) )
|
||||||
}
|
return rc;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,22 +366,6 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Guess boot network device
|
|
||||||
*
|
|
||||||
* @ret netdev Boot network device
|
|
||||||
*/
|
|
||||||
static struct net_device * guess_boot_netdev ( void ) {
|
|
||||||
struct net_device *boot_netdev;
|
|
||||||
|
|
||||||
/* Just use the first network device */
|
|
||||||
for_each_netdev ( boot_netdev ) {
|
|
||||||
return boot_netdev;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare DHCP parameter block for NBI image
|
* Prepare DHCP parameter block for NBI image
|
||||||
*
|
*
|
||||||
@@ -392,7 +376,7 @@ static int nbi_prepare_dhcp ( struct image *image ) {
|
|||||||
struct net_device *boot_netdev;
|
struct net_device *boot_netdev;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
boot_netdev = guess_boot_netdev();
|
boot_netdev = last_opened_netdev();
|
||||||
if ( ! boot_netdev ) {
|
if ( ! boot_netdev ) {
|
||||||
DBGC ( image, "NBI %p could not identify a network device\n",
|
DBGC ( image, "NBI %p could not identify a network device\n",
|
||||||
image );
|
image );
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
*
|
*
|
||||||
@@ -45,29 +47,21 @@ static int pxe_exec ( struct image *image ) {
|
|||||||
struct net_device *netdev;
|
struct net_device *netdev;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Ensure that PXE stack is ready to use */
|
/* Arbitrarily pick the most recently opened network device */
|
||||||
pxe_init_structures();
|
if ( ( netdev = last_opened_netdev() ) == NULL ) {
|
||||||
pxe_hook_int1a();
|
|
||||||
|
|
||||||
/* Arbitrarily pick the first open network device to use for PXE */
|
|
||||||
for_each_netdev ( netdev ) {
|
|
||||||
pxe_set_netdev ( netdev );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Many things will break if pxe_netdev is NULL */
|
|
||||||
if ( ! pxe_netdev ) {
|
|
||||||
DBGC ( image, "IMAGE %p could not locate PXE net device\n",
|
DBGC ( image, "IMAGE %p could not locate PXE net device\n",
|
||||||
image );
|
image );
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Activate PXE */
|
||||||
|
pxe_activate ( netdev );
|
||||||
|
|
||||||
/* Start PXE NBP */
|
/* Start PXE NBP */
|
||||||
rc = pxe_start_nbp();
|
rc = pxe_start_nbp();
|
||||||
|
|
||||||
/* Deactivate PXE */
|
/* Deactivate PXE */
|
||||||
pxe_set_netdev ( NULL );
|
pxe_deactivate();
|
||||||
pxe_unhook_int1a();
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -92,6 +86,12 @@ int pxe_load ( struct image *image ) {
|
|||||||
if ( filesz > ( 0xa0000 - 0x7c00 ) )
|
if ( filesz > ( 0xa0000 - 0x7c00 ) )
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
||||||
|
/* Rejecting zero-length images is also useful, since these
|
||||||
|
* end up looking to the user like bugs in gPXE.
|
||||||
|
*/
|
||||||
|
if ( ! filesz )
|
||||||
|
return -ENOEXEC;
|
||||||
|
|
||||||
/* There are no signature checks for PXE; we will accept anything */
|
/* There are no signature checks for PXE; we will accept anything */
|
||||||
if ( ! image->type )
|
if ( ! image->type )
|
||||||
image->type = &pxe_image_type;
|
image->type = &pxe_image_type;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
#include <bios.h>
|
#include <bios.h>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef BASEMEM_PACKET_H
|
#ifndef BASEMEM_PACKET_H
|
||||||
#define BASEMEM_PACKET_H
|
#define BASEMEM_PACKET_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
|
|
||||||
/** Maximum length of base memory packet buffer */
|
/** Maximum length of base memory packet buffer */
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#ifndef BIOS_H
|
#ifndef BIOS_H
|
||||||
#define BIOS_H
|
#define BIOS_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#define BDA_SEG 0x0040
|
#define BDA_SEG 0x0040
|
||||||
#define BDA_FBMS 0x0013
|
#define BDA_FBMS 0x0013
|
||||||
#define BDA_NUM_DRIVES 0x0075
|
#define BDA_NUM_DRIVES 0x0075
|
||||||
|
|
||||||
extern unsigned long currticks ( void );
|
|
||||||
extern void cpu_nap ( void );
|
|
||||||
|
|
||||||
#endif /* BIOS_H */
|
#endif /* BIOS_H */
|
||||||
|
|||||||
@@ -6,9 +6,24 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <realmode.h>
|
||||||
|
|
||||||
struct segoff;
|
struct segoff;
|
||||||
|
|
||||||
extern int hooked_bios_interrupts;
|
/**
|
||||||
|
* Hooked interrupt count
|
||||||
|
*
|
||||||
|
* At exit, after unhooking all possible interrupts, this counter
|
||||||
|
* should be examined. If it is non-zero, it means that we failed to
|
||||||
|
* unhook at least one interrupt vector, and so must not free up the
|
||||||
|
* memory we are using. (Note that this also implies that we should
|
||||||
|
* re-hook INT 15 in order to hide ourselves from the memory map).
|
||||||
|
*/
|
||||||
|
extern uint16_t __text16 ( hooked_bios_interrupts );
|
||||||
|
#define hooked_bios_interrupts __use_text16 ( hooked_bios_interrupts )
|
||||||
|
|
||||||
extern void hook_bios_interrupt ( unsigned int interrupt, unsigned int handler,
|
extern void hook_bios_interrupt ( unsigned int interrupt, unsigned int handler,
|
||||||
struct segoff *chain_vector );
|
struct segoff *chain_vector );
|
||||||
extern int unhook_bios_interrupt ( unsigned int interrupt,
|
extern int unhook_bios_interrupt ( unsigned int interrupt,
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#ifndef ETHERBOOT_BITS_BYTESWAP_H
|
#ifndef ETHERBOOT_BITS_BYTESWAP_H
|
||||||
#define ETHERBOOT_BITS_BYTESWAP_H
|
#define ETHERBOOT_BITS_BYTESWAP_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
static inline __attribute__ ((always_inline, const)) uint16_t
|
static inline __attribute__ ((always_inline, const)) uint16_t
|
||||||
__i386_bswap_16(uint16_t x)
|
__bswap_variable_16(uint16_t x)
|
||||||
{
|
{
|
||||||
__asm__("xchgb %b0,%h0\n\t"
|
__asm__("xchgb %b0,%h0\n\t"
|
||||||
: "=q" (x)
|
: "=q" (x)
|
||||||
@@ -11,7 +13,7 @@ __i386_bswap_16(uint16_t x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline __attribute__ ((always_inline, const)) uint32_t
|
static inline __attribute__ ((always_inline, const)) uint32_t
|
||||||
__i386_bswap_32(uint32_t x)
|
__bswap_variable_32(uint32_t x)
|
||||||
{
|
{
|
||||||
__asm__("xchgb %b0,%h0\n\t"
|
__asm__("xchgb %b0,%h0\n\t"
|
||||||
"rorl $16,%0\n\t"
|
"rorl $16,%0\n\t"
|
||||||
@@ -22,7 +24,7 @@ __i386_bswap_32(uint32_t x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline __attribute__ ((always_inline, const)) uint64_t
|
static inline __attribute__ ((always_inline, const)) uint64_t
|
||||||
__i386_bswap_64(uint64_t x)
|
__bswap_variable_64(uint64_t x)
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
uint64_t qword;
|
uint64_t qword;
|
||||||
@@ -30,47 +32,12 @@ __i386_bswap_64(uint64_t x)
|
|||||||
} u;
|
} u;
|
||||||
|
|
||||||
u.qword = x;
|
u.qword = x;
|
||||||
u.dword[0] = __i386_bswap_32(u.dword[0]);
|
u.dword[0] = __bswap_variable_32(u.dword[0]);
|
||||||
u.dword[1] = __i386_bswap_32(u.dword[1]);
|
u.dword[1] = __bswap_variable_32(u.dword[1]);
|
||||||
__asm__("xchgl %0,%1"
|
__asm__("xchgl %0,%1"
|
||||||
: "=r" ( u.dword[0] ), "=r" ( u.dword[1] )
|
: "=r" ( u.dword[0] ), "=r" ( u.dword[1] )
|
||||||
: "0" ( u.dword[0] ), "1" ( u.dword[1] ) );
|
: "0" ( u.dword[0] ), "1" ( u.dword[1] ) );
|
||||||
return u.qword;
|
return u.qword;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __bswap_constant_16(x) \
|
|
||||||
((uint16_t)((((uint16_t)(x) & 0x00ff) << 8) | \
|
|
||||||
(((uint16_t)(x) & 0xff00) >> 8)))
|
|
||||||
|
|
||||||
#define __bswap_constant_32(x) \
|
|
||||||
((uint32_t)((((uint32_t)(x) & 0x000000ffU) << 24) | \
|
|
||||||
(((uint32_t)(x) & 0x0000ff00U) << 8) | \
|
|
||||||
(((uint32_t)(x) & 0x00ff0000U) >> 8) | \
|
|
||||||
(((uint32_t)(x) & 0xff000000U) >> 24)))
|
|
||||||
|
|
||||||
#define __bswap_constant_64(x) \
|
|
||||||
((uint64_t)((((uint64_t)(x) & 0x00000000000000ffULL) << 56) | \
|
|
||||||
(((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
|
|
||||||
(((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
|
|
||||||
(((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
|
|
||||||
(((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
|
|
||||||
(((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
|
|
||||||
(((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
|
|
||||||
(((uint64_t)(x) & 0xff00000000000000ULL) >> 56)))
|
|
||||||
|
|
||||||
#define __bswap_16(x) \
|
|
||||||
((uint16_t)(__builtin_constant_p(x) ? \
|
|
||||||
__bswap_constant_16(x) : \
|
|
||||||
__i386_bswap_16(x)))
|
|
||||||
|
|
||||||
#define __bswap_32(x) \
|
|
||||||
((uint32_t)(__builtin_constant_p(x) ? \
|
|
||||||
__bswap_constant_32(x) : \
|
|
||||||
__i386_bswap_32(x)))
|
|
||||||
|
|
||||||
#define __bswap_64(x) \
|
|
||||||
((uint64_t)(__builtin_constant_p(x) ? \
|
|
||||||
__bswap_constant_64(x) : \
|
|
||||||
__i386_bswap_64(x)))
|
|
||||||
|
|
||||||
#endif /* ETHERBOOT_BITS_BYTESWAP_H */
|
#endif /* ETHERBOOT_BITS_BYTESWAP_H */
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef _BITS_COMPILER_H
|
||||||
|
#define _BITS_COMPILER_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#ifndef ASSEMBLY
|
||||||
|
|
||||||
|
/** Declare a function with standard calling conventions */
|
||||||
|
#define __asmcall __attribute__ (( cdecl, regparm(0) ))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare a function with libgcc implicit linkage
|
||||||
|
*
|
||||||
|
* It seems as though gcc expects its implicit arithmetic functions to
|
||||||
|
* be cdecl, even if -mrtd is specified. This is somewhat
|
||||||
|
* inconsistent; for example, if -mregparm=3 is used then the implicit
|
||||||
|
* functions do become regparm(3).
|
||||||
|
*
|
||||||
|
* The implicit calls to memcpy() and memset() which gcc can generate
|
||||||
|
* do not seem to have this inconsistency; -mregparm and -mrtd affect
|
||||||
|
* them in the same way as any other function.
|
||||||
|
*/
|
||||||
|
#define __libgcc __attribute__ (( cdecl ))
|
||||||
|
|
||||||
|
#endif /* ASSEMBLY */
|
||||||
|
|
||||||
|
#endif /* _BITS_COMPILER_H */
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
#ifndef I386_BITS_ELF_H
|
|
||||||
#define I386_BITS_ELF_H
|
|
||||||
|
|
||||||
#include "cpu.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
|
||||||
/* ELF Defines for the 64bit version of the current architecture */
|
|
||||||
#define EM_CURRENT_64 EM_X86_64
|
|
||||||
#define EM_CURRENT_64_PRESENT ( \
|
|
||||||
CPU_FEATURE_P(cpu_info.x86_capability, LM) && \
|
|
||||||
CPU_FEATURE_P(cpu_info.x86_capability, PAE) && \
|
|
||||||
CPU_FEATURE_P(cpu_info.x86_capability, PSE))
|
|
||||||
|
|
||||||
#define ELF_CHECK_X86_64_ARCH(x) \
|
|
||||||
(EM_CURRENT_64_PRESENT && ((x).e_machine == EM_X86_64))
|
|
||||||
#define __unused_i386
|
|
||||||
#else
|
|
||||||
#define ELF_CHECK_X86_64_ARCH(x) 0
|
|
||||||
#define __unused_i386 __unused
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* ELF Defines for the current architecture */
|
|
||||||
#define EM_CURRENT EM_386
|
|
||||||
#define ELFDATA_CURRENT ELFDATA2LSB
|
|
||||||
|
|
||||||
#define ELF_CHECK_I386_ARCH(x) \
|
|
||||||
(((x).e_machine == EM_386) || ((x).e_machine == EM_486))
|
|
||||||
|
|
||||||
#define ELF_CHECK_ARCH(x) \
|
|
||||||
((ELF_CHECK_I386_ARCH(x) || ELF_CHECK_X86_64_ARCH(x)) && \
|
|
||||||
((x).e_entry <= 0xffffffffUL))
|
|
||||||
|
|
||||||
#ifdef IMAGE_FREEBSD
|
|
||||||
/*
|
|
||||||
* FreeBSD has this rather strange "feature" of its design.
|
|
||||||
* At some point in its evolution, FreeBSD started to rely
|
|
||||||
* externally on private/static/debug internal symbol information.
|
|
||||||
* That is, some of the interfaces that software uses to access
|
|
||||||
* and work with the FreeBSD kernel are made available not
|
|
||||||
* via the shared library symbol information (the .DYNAMIC section)
|
|
||||||
* but rather the debug symbols. This means that any symbol, not
|
|
||||||
* just publicly defined symbols can be (and are) used by system
|
|
||||||
* tools to make the system work. (such as top, swapinfo, swapon,
|
|
||||||
* etc)
|
|
||||||
*
|
|
||||||
* Even worse, however, is the fact that standard ELF loaders do
|
|
||||||
* not know how to load the symbols since they are not within
|
|
||||||
* an ELF PT_LOAD section. The kernel needs these symbols to
|
|
||||||
* operate so the following changes/additions to the boot
|
|
||||||
* loading of EtherBoot have been made to get the kernel to load.
|
|
||||||
* All of the changes are within IMAGE_FREEBSD such that the
|
|
||||||
* extra/changed code only compiles when FREEBSD support is
|
|
||||||
* enabled.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Section header for FreeBSD (debug symbol kludge!) support
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Word sh_name; /* Section name (index into the
|
|
||||||
section header string table). */
|
|
||||||
Elf32_Word sh_type; /* Section type. */
|
|
||||||
Elf32_Word sh_flags; /* Section flags. */
|
|
||||||
Elf32_Addr sh_addr; /* Address in memory image. */
|
|
||||||
Elf32_Off sh_offset; /* Offset in file. */
|
|
||||||
Elf32_Size sh_size; /* Size in bytes. */
|
|
||||||
Elf32_Word sh_link; /* Index of a related section. */
|
|
||||||
Elf32_Word sh_info; /* Depends on section type. */
|
|
||||||
Elf32_Size sh_addralign; /* Alignment in bytes. */
|
|
||||||
Elf32_Size sh_entsize; /* Size of each entry in section. */
|
|
||||||
} Elf32_Shdr;
|
|
||||||
|
|
||||||
/* sh_type */
|
|
||||||
#define SHT_SYMTAB 2 /* symbol table section */
|
|
||||||
#define SHT_STRTAB 3 /* string table section */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Module information subtypes (for the metadata that we need to build)
|
|
||||||
*/
|
|
||||||
#define MODINFO_END 0x0000 /* End of list */
|
|
||||||
#define MODINFO_NAME 0x0001 /* Name of module (string) */
|
|
||||||
#define MODINFO_TYPE 0x0002 /* Type of module (string) */
|
|
||||||
#define MODINFO_METADATA 0x8000 /* Module-specfic */
|
|
||||||
|
|
||||||
#define MODINFOMD_SSYM 0x0003 /* start of symbols */
|
|
||||||
#define MODINFOMD_ESYM 0x0004 /* end of symbols */
|
|
||||||
|
|
||||||
#endif /* IMAGE_FREEBSD */
|
|
||||||
|
|
||||||
#endif /* I386_BITS_ELF_H */
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#define ARCH_ELF_CLASS ELFCLASS32
|
|
||||||
#define ARCH_ELF_DATA ELFDATA2LSB
|
|
||||||
#define ARCH_ELF_MACHINE_OK(x) ((x)==EM_386 || (x)==EM_486)
|
|
||||||
typedef Elf32_Ehdr Elf_ehdr;
|
|
||||||
typedef Elf32_Phdr Elf_phdr;
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef ETHERBOOT_BITS_ENDIAN_H
|
#ifndef ETHERBOOT_BITS_ENDIAN_H
|
||||||
#define ETHERBOOT_BITS_ENDIAN_H
|
#define ETHERBOOT_BITS_ENDIAN_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||||
|
|
||||||
#endif /* ETHERBOOT_BITS_ENDIAN_H */
|
#endif /* ETHERBOOT_BITS_ENDIAN_H */
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
#ifndef _BITS_ERRFILE_H
|
#ifndef _BITS_ERRFILE_H
|
||||||
#define _BITS_ERRFILE_H
|
#define _BITS_ERRFILE_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup errfile Error file identifiers
|
* @addtogroup errfile Error file identifiers
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ERRFILE_umalloc ( ERRFILE_ARCH | ERRFILE_CORE | 0x00000000 )
|
#define ERRFILE_memtop_umalloc ( ERRFILE_ARCH | ERRFILE_CORE | 0x00000000 )
|
||||||
#define ERRFILE_memmap ( ERRFILE_ARCH | ERRFILE_CORE | 0x00010000 )
|
#define ERRFILE_memmap ( ERRFILE_ARCH | ERRFILE_CORE | 0x00010000 )
|
||||||
#define ERRFILE_pnpbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00020000 )
|
#define ERRFILE_pnpbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00020000 )
|
||||||
#define ERRFILE_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
|
#define ERRFILE_bios_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
|
||||||
#define ERRFILE_biosint ( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
|
#define ERRFILE_biosint ( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
|
||||||
#define ERRFILE_int13 ( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
|
#define ERRFILE_int13 ( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
|
||||||
#define ERRFILE_smbios_settings ( ERRFILE_ARCH | ERRFILE_CORE | 0x00060000 )
|
|
||||||
|
|
||||||
#define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
|
#define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
|
||||||
#define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
|
#define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
#define ERRFILE_comboot ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00070000 )
|
#define ERRFILE_comboot ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00070000 )
|
||||||
#define ERRFILE_com32 ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00080000 )
|
#define ERRFILE_com32 ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00080000 )
|
||||||
#define ERRFILE_comboot_resolv ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00090000 )
|
#define ERRFILE_comboot_resolv ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00090000 )
|
||||||
|
#define ERRFILE_comboot_call ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000a0000 )
|
||||||
|
|
||||||
#define ERRFILE_undi ( ERRFILE_ARCH | ERRFILE_NET | 0x00000000 )
|
#define ERRFILE_undi ( ERRFILE_ARCH | ERRFILE_NET | 0x00000000 )
|
||||||
#define ERRFILE_undiload ( ERRFILE_ARCH | ERRFILE_NET | 0x00010000 )
|
#define ERRFILE_undiload ( ERRFILE_ARCH | ERRFILE_NET | 0x00010000 )
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef _BITS_IO_H
|
||||||
|
#define _BITS_IO_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* i386-specific I/O API implementations
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <gpxe/x86_io.h>
|
||||||
|
|
||||||
|
#endif /* _BITS_IO_H */
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef _BITS_NAP_H
|
||||||
|
#define _BITS_NAP_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* i386-specific CPU sleeping API implementations
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <gpxe/bios_nap.h>
|
||||||
|
#include <gpxe/efi/efix86_nap.h>
|
||||||
|
|
||||||
|
#endif /* _BITS_MAP_H */
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef _BITS_SMBIOS_H
|
||||||
|
#define _BITS_SMBIOS_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* i386-specific SMBIOS API implementations
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <gpxe/bios_smbios.h>
|
||||||
|
|
||||||
|
#endif /* _BITS_SMBIOS_H */
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
#ifndef _BITS_STDINT_H
|
#ifndef _BITS_STDINT_H
|
||||||
#define _BITS_STDINT_H
|
#define _BITS_STDINT_H
|
||||||
|
|
||||||
typedef typeof(sizeof(int)) size_t;
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
typedef __SIZE_TYPE__ size_t;
|
||||||
typedef signed long ssize_t;
|
typedef signed long ssize_t;
|
||||||
typedef signed long off_t;
|
typedef signed long off_t;
|
||||||
|
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned short uint16_t;
|
typedef unsigned short uint16_t;
|
||||||
typedef unsigned long uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
typedef unsigned long long uint64_t;
|
typedef unsigned long long uint64_t;
|
||||||
|
|
||||||
typedef signed char int8_t;
|
typedef signed char int8_t;
|
||||||
typedef signed short int16_t;
|
typedef signed short int16_t;
|
||||||
typedef signed long int32_t;
|
typedef signed int int32_t;
|
||||||
typedef signed long long int64_t;
|
typedef signed long long int64_t;
|
||||||
|
|
||||||
typedef unsigned long physaddr_t;
|
typedef unsigned long physaddr_t;
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef _BITS_TIMER_H
|
||||||
|
#define _BITS_TIMER_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* i386-specific timer API implementations
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <gpxe/bios_timer.h>
|
||||||
|
#include <gpxe/rdtsc_timer.h>
|
||||||
|
|
||||||
|
#endif /* _BITS_TIMER_H */
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef BITS_TIMER2_H
|
|
||||||
#define BITS_TIMER2_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
void i386_timer2_udelay(unsigned int usecs);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
#ifndef _BITS_UACCESS_H
|
#ifndef _BITS_UACCESS_H
|
||||||
#define _BITS_UACCESS_H
|
#define _BITS_UACCESS_H
|
||||||
|
|
||||||
#include <realmode.h>
|
/** @file
|
||||||
|
*
|
||||||
|
* i386-specific user access API implementations
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <librm.h>
|
||||||
|
|
||||||
#endif /* _BITS_UACCESS_H */
|
#endif /* _BITS_UACCESS_H */
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef _BITS_UMALLOC_H
|
||||||
|
#define _BITS_UMALLOC_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* i386-specific user memory allocation API implementations
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <gpxe/memtop_umalloc.h>
|
||||||
|
|
||||||
|
#endif /* _BITS_UMALLOC_H */
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
* x86 bootsector image format
|
* x86 bootsector image format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
extern int call_bootsector ( unsigned int segment, unsigned int offset,
|
extern int call_bootsector ( unsigned int segment, unsigned int offset,
|
||||||
unsigned int drive );
|
unsigned int drive );
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef _BZIMAGE_H
|
#ifndef _BZIMAGE_H
|
||||||
#define _BZIMAGE_H
|
#define _BZIMAGE_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,6 +77,9 @@ struct bzimage_header {
|
|||||||
/** Offset of bzImage header within kernel image */
|
/** Offset of bzImage header within kernel image */
|
||||||
#define BZI_HDR_OFFSET 0x1f1
|
#define BZI_HDR_OFFSET 0x1f1
|
||||||
|
|
||||||
|
/** bzImage boot flag value */
|
||||||
|
#define BZI_BOOT_FLAG 0xaa55
|
||||||
|
|
||||||
/** bzImage magic signature value */
|
/** bzImage magic signature value */
|
||||||
#define BZI_SIGNATURE 0x53726448
|
#define BZI_SIGNATURE 0x53726448
|
||||||
|
|
||||||
|
|||||||
@@ -1,243 +0,0 @@
|
|||||||
/* Callout/callback interface for Etherboot
|
|
||||||
*
|
|
||||||
* This file provides the mechanisms for making calls from Etherboot
|
|
||||||
* to external programs and vice-versa.
|
|
||||||
*
|
|
||||||
* Initial version by Michael Brown <mbrown@fensystems.co.uk>, January 2004.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CALLBACKS_ARCH_H
|
|
||||||
#define CALLBACKS_ARCH_H
|
|
||||||
|
|
||||||
/* Skip the definitions that won't make sense to the assembler */
|
|
||||||
#ifndef ASSEMBLY
|
|
||||||
|
|
||||||
/* Struct to hold general-purpose register values. PUSHAL and POPAL
|
|
||||||
* can work directly with this structure; do not change the order of
|
|
||||||
* registers.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
union {
|
|
||||||
uint16_t di;
|
|
||||||
uint32_t edi;
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
uint16_t si;
|
|
||||||
uint32_t esi;
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
uint16_t bp;
|
|
||||||
uint32_t ebp;
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
uint16_t sp;
|
|
||||||
uint32_t esp;
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
uint8_t bl;
|
|
||||||
uint8_t bh;
|
|
||||||
} PACKED;
|
|
||||||
uint16_t bx;
|
|
||||||
uint32_t ebx;
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
uint8_t dl;
|
|
||||||
uint8_t dh;
|
|
||||||
} PACKED;
|
|
||||||
uint16_t dx;
|
|
||||||
uint32_t edx;
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
uint8_t cl;
|
|
||||||
uint8_t ch;
|
|
||||||
} PACKED;
|
|
||||||
uint16_t cx;
|
|
||||||
uint32_t ecx;
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
uint8_t al;
|
|
||||||
uint8_t ah;
|
|
||||||
} PACKED;
|
|
||||||
uint16_t ax;
|
|
||||||
uint32_t eax;
|
|
||||||
};
|
|
||||||
} regs_t;
|
|
||||||
|
|
||||||
/* Struct to hold segment register values. Don't change the order;
|
|
||||||
* many bits of assembly code rely on it.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
uint16_t cs;
|
|
||||||
uint16_t ss;
|
|
||||||
uint16_t ds;
|
|
||||||
uint16_t es;
|
|
||||||
uint16_t fs;
|
|
||||||
uint16_t gs;
|
|
||||||
} PACKED seg_regs_t;
|
|
||||||
|
|
||||||
/* Struct for a GDT descriptor */
|
|
||||||
typedef struct {
|
|
||||||
uint16_t limit;
|
|
||||||
uint32_t address;
|
|
||||||
uint16_t padding;
|
|
||||||
} PACKED gdt_descriptor_t;
|
|
||||||
|
|
||||||
/* Struct for a GDT entry. Use GDT_SEGMENT() to fill it in.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
uint16_t limit_0_15;
|
|
||||||
uint16_t base_0_15;
|
|
||||||
uint8_t base_16_23;
|
|
||||||
uint8_t accessed__type__sflag__dpl__present;
|
|
||||||
uint8_t limit_16_19__avl__size__granularity;
|
|
||||||
uint8_t base_24_31;
|
|
||||||
} PACKED gdt_segment_t;
|
|
||||||
|
|
||||||
#define GDT_SEGMENT(base,limit,type,sflag,dpl,avl,size,granularity) \
|
|
||||||
( (gdt_segment_t) { \
|
|
||||||
( (limit) & 0xffff ), \
|
|
||||||
( (base) & 0xffff ), \
|
|
||||||
( ( (base) >> 16 ) & 0xff ), \
|
|
||||||
( ( 1 << 0 ) | ( (type) << 1 ) | \
|
|
||||||
( (sflag) << 4 ) | ( (dpl) << 5 ) | ( 1 << 7 ) ), \
|
|
||||||
( ( (limit) >> 16 ) | \
|
|
||||||
( (avl) << 4 ) | ( (size) << 5 ) | ( (granularity) << 7 ) ),\
|
|
||||||
( (base) >> 24 ) \
|
|
||||||
} )
|
|
||||||
#define GDT_SEGMENT_BASE(gdt_segment) \
|
|
||||||
( (gdt_segment)->base_0_15 | \
|
|
||||||
(gdt_segment)->base_16_23 << 16 | \
|
|
||||||
(gdt_segment)->base_24_31 << 24 )
|
|
||||||
#define GDT_SEGMENT_LIMIT(gdt_segment) \
|
|
||||||
( (gdt_segment)->limit_0_15 | \
|
|
||||||
( ( (gdt_segment)->limit_16_19__avl__size__granularity \
|
|
||||||
& 0xf ) << 16 ) )
|
|
||||||
#define GDT_SEGMENT_GRANULARITY(gdt_segment) \
|
|
||||||
( ( (gdt_segment)->limit_16_19__avl__size__granularity \
|
|
||||||
& 0x80 ) >> 7 )
|
|
||||||
#define GDT_SEGMENT_TYPE(gdt_segment) \
|
|
||||||
( ( (gdt_segment)->accessed__type__sflag__dpl__present & 0x0e ) >> 1 )
|
|
||||||
#define GDT_SEGMENT_SIZE(gdt_segment) \
|
|
||||||
( ( (gdt_segment)->limit_16_19__avl__size__granularity \
|
|
||||||
& 0x60 ) >> 5 )
|
|
||||||
|
|
||||||
#define GDT_TYPE_DATA (0x0)
|
|
||||||
#define GDT_TYPE_STACK (0x2)
|
|
||||||
#define GDT_TYPE_WRITEABLE (0x1)
|
|
||||||
#define GDT_TYPE_CODE (0x6)
|
|
||||||
#define GDT_TYPE_EXEC_ONLY_CODE (0x4)
|
|
||||||
#define GDT_TYPE_CONFORMING (0x1)
|
|
||||||
#define GDT_SFLAG_SYSTEM (0)
|
|
||||||
#define GDT_SFLAG_NORMAL (1)
|
|
||||||
#define GDT_AVL_NORMAL (0)
|
|
||||||
#define GDT_SIZE_16BIT (0x0)
|
|
||||||
#define GDT_SIZE_32BIT (0x2)
|
|
||||||
#define GDT_SIZE_64BIT (0x1)
|
|
||||||
#define GDT_SIZE_UNKNOWN (0x3)
|
|
||||||
#define GDT_GRANULARITY_SMALL (0)
|
|
||||||
#define GDT_GRANULARITY_LARGE (1)
|
|
||||||
#define GDT_SEGMENT_NORMAL(base,limit,type,size,granularity) \
|
|
||||||
GDT_SEGMENT ( base, limit, type, \
|
|
||||||
GDT_SFLAG_NORMAL, 0, GDT_AVL_NORMAL, \
|
|
||||||
size, granularity )
|
|
||||||
|
|
||||||
/* Protected mode code segment */
|
|
||||||
#define GDT_SEGMENT_PMCS(base) GDT_SEGMENT_NORMAL ( \
|
|
||||||
base, 0xfffff, GDT_TYPE_CODE | GDT_TYPE_CONFORMING, \
|
|
||||||
GDT_SIZE_32BIT, GDT_GRANULARITY_LARGE )
|
|
||||||
#define GDT_SEGMENT_PMCS_PHYS GDT_SEGMENT_PMCS(0)
|
|
||||||
/* Protected mode data segment */
|
|
||||||
#define GDT_SEGMENT_PMDS(base) GDT_SEGMENT_NORMAL ( \
|
|
||||||
base, 0xfffff, GDT_TYPE_DATA | GDT_TYPE_WRITEABLE, \
|
|
||||||
GDT_SIZE_32BIT, GDT_GRANULARITY_LARGE )
|
|
||||||
#define GDT_SEGMENT_PMDS_PHYS GDT_SEGMENT_PMDS(0)
|
|
||||||
/* Real mode code segment */
|
|
||||||
/* Not sure if there's any reason to use GDT_TYPE_EXEC_ONLY_CODE
|
|
||||||
* instead of just GDT_TYPE_CODE, but that's what our old GDT did and
|
|
||||||
* it worked, so I'm not changing it.
|
|
||||||
*/
|
|
||||||
#define GDT_SEGMENT_RMCS(base) GDT_SEGMENT_NORMAL ( \
|
|
||||||
base, 0xffff, GDT_TYPE_EXEC_ONLY_CODE | GDT_TYPE_CONFORMING, \
|
|
||||||
GDT_SIZE_16BIT, GDT_GRANULARITY_SMALL )
|
|
||||||
/* Real mode data segment */
|
|
||||||
#define GDT_SEGMENT_RMDS(base) GDT_SEGMENT_NORMAL ( \
|
|
||||||
base, 0xffff, GDT_TYPE_DATA | GDT_TYPE_WRITEABLE, \
|
|
||||||
GDT_SIZE_16BIT, GDT_GRANULARITY_SMALL )
|
|
||||||
/* Long mode code segment */
|
|
||||||
#define GDT_SEGMENT_LMCS(base) GDT_SEGMENT_NORMAL ( \
|
|
||||||
base, 0xfffff, GDT_TYPE_CODE | GDT_TYPE_CONFORMING, \
|
|
||||||
GDT_SIZE_64BIT, GDT_GRANULARITY_LARGE )
|
|
||||||
#define GDT_SEGMENT_LMCS_PHYS GDT_SEGMENT_LMCS(0)
|
|
||||||
/* Long mode data segment */
|
|
||||||
/* AFIACT, GDT_SIZE_64BIT applies only to code segments */
|
|
||||||
#define GDT_SEGMENT_LMDS(base) GDT_SEGMENT_NORMAL ( \
|
|
||||||
base, 0xfffff, GDT_TYPE_DATA | GDT_TYPE_WRITEABLE, \
|
|
||||||
GDT_SIZE_32BIT, GDT_GRANULARITY_LARGE )
|
|
||||||
#define GDT_SEGMENT_LMDS_PHYS GDT_SEGMENT_LMDS(0)
|
|
||||||
|
|
||||||
/* Template for creating GDT structures (including segment register
|
|
||||||
* lists), suitable for passing as parameters to external_call().
|
|
||||||
*/
|
|
||||||
#define GDT_STRUCT_t(num_segments) \
|
|
||||||
struct { \
|
|
||||||
gdt_descriptor_t descriptor; \
|
|
||||||
gdt_segment_t segments[num_segments]; \
|
|
||||||
} PACKED
|
|
||||||
/* And utility function for filling it in */
|
|
||||||
#define GDT_ADJUST(structure) { \
|
|
||||||
(structure)->descriptor.address = \
|
|
||||||
virt_to_phys(&((structure)->descriptor.limit)); \
|
|
||||||
(structure)->descriptor.limit = \
|
|
||||||
sizeof((structure)->segments) + 8 - 1; \
|
|
||||||
(structure)->descriptor.padding = 0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Data passed in to in_call() by assembly wrapper.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
regs_t regs;
|
|
||||||
seg_regs_t seg_regs;
|
|
||||||
gdt_descriptor_t gdt_desc;
|
|
||||||
uint32_t flags;
|
|
||||||
struct {
|
|
||||||
uint32_t offset;
|
|
||||||
uint32_t segment;
|
|
||||||
} ret_addr;
|
|
||||||
} PACKED i386_pm_in_call_data_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
seg_regs_t seg_regs;
|
|
||||||
union {
|
|
||||||
uint16_t pad;
|
|
||||||
uint16_t prefix_sp;
|
|
||||||
};
|
|
||||||
uint16_t flags;
|
|
||||||
struct {
|
|
||||||
uint16_t offset;
|
|
||||||
uint16_t segment;
|
|
||||||
} ret_addr;
|
|
||||||
uint32_t orig_opcode;
|
|
||||||
} PACKED i386_rm_in_call_data_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
i386_pm_in_call_data_t *pm;
|
|
||||||
i386_rm_in_call_data_t *rm;
|
|
||||||
} i386_in_call_data_t;
|
|
||||||
#define in_call_data_t i386_in_call_data_t
|
|
||||||
|
|
||||||
/* Function prototypes
|
|
||||||
*/
|
|
||||||
extern int install_rm_callback_interface ( void *address, size_t available );
|
|
||||||
|
|
||||||
#endif /* ASSEMBLY */
|
|
||||||
|
|
||||||
#define RM_IN_CALL (0)
|
|
||||||
#define RM_IN_CALL_FAR (2)
|
|
||||||
|
|
||||||
#endif /* CALLBACKS_ARCH_H */
|
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
* SYSLINUX COMBOOT
|
* SYSLINUX COMBOOT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <gpxe/in.h>
|
#include <gpxe/in.h>
|
||||||
@@ -57,6 +59,40 @@ typedef struct {
|
|||||||
com32_reg32_t eflags; /* Offset 40 */
|
com32_reg32_t eflags; /* Offset 40 */
|
||||||
} com32sys_t;
|
} com32sys_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t eax; /* Offset 0 */
|
||||||
|
uint32_t ecx; /* Offset 4 */
|
||||||
|
uint32_t edx; /* Offset 8 */
|
||||||
|
uint32_t ebx; /* Offset 12 */
|
||||||
|
uint32_t esp; /* Offset 16 */
|
||||||
|
uint32_t ebp; /* Offset 20 */
|
||||||
|
uint32_t esi; /* Offset 24 */
|
||||||
|
uint32_t edi; /* Offset 28 */
|
||||||
|
|
||||||
|
uint32_t eip; /* Offset 32 */
|
||||||
|
} syslinux_pm_regs;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t es; /* Offset 0 */
|
||||||
|
uint16_t _unused_cs; /* Offset 2 */
|
||||||
|
uint16_t ds; /* Offset 4 */
|
||||||
|
uint16_t ss; /* Offset 6 */
|
||||||
|
uint16_t fs; /* Offset 8 */
|
||||||
|
uint16_t gs; /* Offset 10 */
|
||||||
|
|
||||||
|
uint32_t eax; /* Offset 12 */
|
||||||
|
uint32_t ecx; /* Offset 16 */
|
||||||
|
uint32_t edx; /* Offset 20 */
|
||||||
|
uint32_t ebx; /* Offset 24 */
|
||||||
|
uint32_t esp; /* Offset 28 */
|
||||||
|
uint32_t ebp; /* Offset 32 */
|
||||||
|
uint32_t esi; /* Offset 36 */
|
||||||
|
uint32_t edi; /* Offset 40 */
|
||||||
|
|
||||||
|
uint16_t ip; /* Offset 44 */
|
||||||
|
uint16_t cs; /* Offset 46 */
|
||||||
|
} syslinux_rm_regs;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t dest;
|
uint32_t dest;
|
||||||
uint32_t src;
|
uint32_t src;
|
||||||
@@ -64,6 +100,7 @@ typedef struct {
|
|||||||
} comboot_shuffle_descriptor;
|
} comboot_shuffle_descriptor;
|
||||||
|
|
||||||
extern void hook_comboot_interrupts ( );
|
extern void hook_comboot_interrupts ( );
|
||||||
|
extern void unhook_comboot_interrupts ( );
|
||||||
|
|
||||||
/* These are not the correct prototypes, but it doens't matter,
|
/* These are not the correct prototypes, but it doens't matter,
|
||||||
* as we only ever get the address of these functions;
|
* as we only ever get the address of these functions;
|
||||||
@@ -77,20 +114,16 @@ extern void com32_cfarcall_wrapper ( );
|
|||||||
extern int comboot_resolv ( const char *name, struct in_addr *address );
|
extern int comboot_resolv ( const char *name, struct in_addr *address );
|
||||||
|
|
||||||
/* setjmp/longjmp context buffer used to return after loading an image */
|
/* setjmp/longjmp context buffer used to return after loading an image */
|
||||||
extern jmp_buf comboot_return;
|
extern rmjmp_buf comboot_return;
|
||||||
|
|
||||||
/* Command line to execute when returning via comboot_return
|
/* Replacement image when exiting with COMBOOT_EXIT_RUN_KERNEL */
|
||||||
* with COMBOOT_RETURN_RUN_KERNEL
|
extern struct image *comboot_replacement_image;
|
||||||
*/
|
|
||||||
extern char *comboot_kernel_cmdline;
|
|
||||||
|
|
||||||
/* Execute comboot_image_cmdline */
|
|
||||||
extern void comboot_run_kernel ( );
|
|
||||||
|
|
||||||
extern void *com32_external_esp;
|
extern void *com32_external_esp;
|
||||||
|
|
||||||
#define COMBOOT_RETURN_EXIT 1
|
#define COMBOOT_EXIT 1
|
||||||
#define COMBOOT_RETURN_RUN_KERNEL 2
|
#define COMBOOT_EXIT_RUN_KERNEL 2
|
||||||
|
#define COMBOOT_EXIT_COMMAND 3
|
||||||
|
|
||||||
extern void comboot_force_text_mode ( void );
|
extern void comboot_force_text_mode ( void );
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef _FAKEE820_H
|
#ifndef _FAKEE820_H
|
||||||
#define _FAKEE820_H
|
#define _FAKEE820_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
extern void fake_e820 ( void );
|
extern void fake_e820 ( void );
|
||||||
extern void unfake_e820 ( void );
|
extern void unfake_e820 ( void );
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef uint32_t gdbreg_t;
|
typedef unsigned long gdbreg_t;
|
||||||
|
|
||||||
/* The register snapshot, this must be in sync with interrupt handler and the
|
/* The register snapshot, this must be in sync with interrupt handler and the
|
||||||
* GDB protocol. */
|
* GDB protocol. */
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <gpxe/acpi.h>
|
#include <gpxe/acpi.h>
|
||||||
#include <gpxe/if_ether.h>
|
#include <gpxe/if_ether.h>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _GPXE_BIOS_NAP_H
|
||||||
|
#define _GPXE_BIOS_NAP_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* BIOS CPU sleeping
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#ifdef NAP_PCBIOS
|
||||||
|
#define NAP_PREFIX_pcbios
|
||||||
|
#else
|
||||||
|
#define NAP_PREFIX_pcbios __pcbios_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _GPXE_BIOS_NAP_H */
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _GPXE_BIOS_SMBIOS_H
|
||||||
|
#define _GPXE_BIOS_SMBIOS_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* Standard PC-BIOS SMBIOS interface
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#ifdef SMBIOS_PCBIOS
|
||||||
|
#define SMBIOS_PREFIX_pcbios
|
||||||
|
#else
|
||||||
|
#define SMBIOS_PREFIX_pcbios __pcbios_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _GPXE_BIOS_SMBIOS_H */
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef _GPXE_BIOS_TIMER_H
|
||||||
|
#define _GPXE_BIOS_TIMER_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* BIOS timer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#ifdef TIMER_PCBIOS
|
||||||
|
#define TIMER_PREFIX_pcbios
|
||||||
|
#else
|
||||||
|
#define TIMER_PREFIX_pcbios __pcbios_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gpxe/timer2.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay for a fixed number of microseconds
|
||||||
|
*
|
||||||
|
* @v usecs Number of microseconds for which to delay
|
||||||
|
*/
|
||||||
|
static inline __always_inline void
|
||||||
|
TIMER_INLINE ( pcbios, udelay ) ( unsigned long usecs ) {
|
||||||
|
/* BIOS timer is not high-resolution enough for udelay(), so
|
||||||
|
* we use timer2
|
||||||
|
*/
|
||||||
|
timer2_udelay ( usecs );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of ticks per second
|
||||||
|
*
|
||||||
|
* @ret ticks_per_sec Number of ticks per second
|
||||||
|
*/
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
TIMER_INLINE ( pcbios, ticks_per_sec ) ( void ) {
|
||||||
|
/* BIOS timer ticks over at 18.2 ticks per second */
|
||||||
|
return 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _GPXE_BIOS_TIMER_H */
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( BSD2 );
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* iSCSI boot firmware table
|
* iSCSI boot firmware table
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _GPXE_MEMTOP_UMALLOC_H
|
||||||
|
#define _GPXE_MEMTOP_UMALLOC_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* External memory allocation
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#ifdef UMALLOC_MEMTOP
|
||||||
|
#define UMALLOC_PREFIX_memtop
|
||||||
|
#else
|
||||||
|
#define UMALLOC_PREFIX_memtop __memtop_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _GPXE_MEMTOP_UMALLOC_H */
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef _GPXE_RDTSC_TIMER_H
|
||||||
|
#define _GPXE_RDTSC_TIMER_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* RDTSC timer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#ifdef TIMER_RDTSC
|
||||||
|
#define TIMER_PREFIX_rdtsc
|
||||||
|
#else
|
||||||
|
#define TIMER_PREFIX_rdtsc __rdtsc_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RDTSC values can easily overflow an unsigned long. We discard the
|
||||||
|
* low-order bits in order to obtain sensibly-scaled values.
|
||||||
|
*/
|
||||||
|
#define TSC_SHIFT 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current system time in ticks
|
||||||
|
*
|
||||||
|
* @ret ticks Current time, in ticks
|
||||||
|
*/
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
TIMER_INLINE ( rdtsc, currticks ) ( void ) {
|
||||||
|
unsigned long ticks;
|
||||||
|
|
||||||
|
__asm__ __volatile__ ( "rdtsc\n\t"
|
||||||
|
"shrdl %1, %%edx, %%eax\n\t"
|
||||||
|
: "=a" ( ticks ) : "i" ( TSC_SHIFT ) : "edx" );
|
||||||
|
return ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _GPXE_RDTSC_TIMER_H */
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
#ifndef _GPXE_SBFT_H
|
||||||
|
#define _GPXE_SBFT_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( BSD2 );
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* SRP boot firmware table
|
||||||
|
*
|
||||||
|
* The working draft specification for the SRP boot firmware table can
|
||||||
|
* be found at
|
||||||
|
*
|
||||||
|
* http://etherboot.org/wiki/srp/sbft
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <gpxe/acpi.h>
|
||||||
|
#include <gpxe/scsi.h>
|
||||||
|
#include <gpxe/srp.h>
|
||||||
|
#include <gpxe/ib_srp.h>
|
||||||
|
|
||||||
|
/** SRP Boot Firmware Table signature */
|
||||||
|
#define SBFT_SIG "sBFT"
|
||||||
|
|
||||||
|
/** An offset from the start of the sBFT */
|
||||||
|
typedef uint16_t sbft_off_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SRP Boot Firmware Table
|
||||||
|
*/
|
||||||
|
struct sbft_table {
|
||||||
|
/** ACPI header */
|
||||||
|
struct acpi_description_header acpi;
|
||||||
|
/** Offset to SCSI subtable */
|
||||||
|
sbft_off_t scsi_offset;
|
||||||
|
/** Offset to SRP subtable */
|
||||||
|
sbft_off_t srp_offset;
|
||||||
|
/** Offset to IB subtable, if present */
|
||||||
|
sbft_off_t ib_offset;
|
||||||
|
/** Reserved */
|
||||||
|
uint8_t reserved[6];
|
||||||
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sBFT SCSI subtable
|
||||||
|
*/
|
||||||
|
struct sbft_scsi_subtable {
|
||||||
|
/** LUN */
|
||||||
|
struct scsi_lun lun;
|
||||||
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sBFT SRP subtable
|
||||||
|
*/
|
||||||
|
struct sbft_srp_subtable {
|
||||||
|
/** Initiator and target ports */
|
||||||
|
struct srp_port_ids port_ids;
|
||||||
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sBFT IB subtable
|
||||||
|
*/
|
||||||
|
struct sbft_ib_subtable {
|
||||||
|
/** Source GID */
|
||||||
|
struct ib_gid sgid;
|
||||||
|
/** Destination GID */
|
||||||
|
struct ib_gid dgid;
|
||||||
|
/** Service ID */
|
||||||
|
struct ib_gid_half service_id;
|
||||||
|
/** Partition key */
|
||||||
|
uint16_t pkey;
|
||||||
|
/** Reserved */
|
||||||
|
uint8_t reserved[6];
|
||||||
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An sBFT created by gPXE
|
||||||
|
*/
|
||||||
|
struct gpxe_sbft {
|
||||||
|
/** The table header */
|
||||||
|
struct sbft_table table;
|
||||||
|
/** The SCSI subtable */
|
||||||
|
struct sbft_scsi_subtable scsi;
|
||||||
|
/** The SRP subtable */
|
||||||
|
struct sbft_srp_subtable srp;
|
||||||
|
/** The IB subtable */
|
||||||
|
struct sbft_ib_subtable ib;
|
||||||
|
} __attribute__ (( packed, aligned ( 16 ) ));
|
||||||
|
|
||||||
|
struct srp_device;
|
||||||
|
|
||||||
|
extern int sbft_fill_data ( struct srp_device *srp );
|
||||||
|
|
||||||
|
#endif /* _GPXE_SBFT_H */
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef _GPXE_TIMER2_H
|
||||||
|
#define _GPXE_TIMER2_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* Timer chip control
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
extern void timer2_udelay ( unsigned long usecs );
|
||||||
|
|
||||||
|
#endif /* _GPXE_TIMER2_H */
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
#ifndef _GPXE_X86_IO_H
|
||||||
|
#define _GPXE_X86_IO_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* gPXE I/O API for x86
|
||||||
|
*
|
||||||
|
* i386 uses direct pointer dereferences for accesses to memory-mapped
|
||||||
|
* I/O space, and the inX/outX instructions for accesses to
|
||||||
|
* port-mapped I/O space.
|
||||||
|
*
|
||||||
|
* 64-bit atomic accesses (readq() and writeq()) use MMX instructions,
|
||||||
|
* and will crash original Pentium and earlier CPUs. Fortunately, no
|
||||||
|
* hardware that requires atomic 64-bit accesses will physically fit
|
||||||
|
* into a machine with such an old CPU anyway.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#ifdef IOAPI_X86
|
||||||
|
#define IOAPI_PREFIX_x86
|
||||||
|
#else
|
||||||
|
#define IOAPI_PREFIX_x86 __x86_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Memory space mappings
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Physical<->Bus and Bus<->I/O address mappings
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
IOAPI_INLINE ( x86, phys_to_bus ) ( unsigned long phys_addr ) {
|
||||||
|
return phys_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
IOAPI_INLINE ( x86, bus_to_phys ) ( unsigned long bus_addr ) {
|
||||||
|
return bus_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline void *
|
||||||
|
IOAPI_INLINE ( x86, ioremap ) ( unsigned long bus_addr, size_t len __unused ) {
|
||||||
|
return phys_to_virt ( bus_addr );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline void
|
||||||
|
IOAPI_INLINE ( x86, iounmap ) ( volatile const void *io_addr __unused ) {
|
||||||
|
/* Nothing to do */
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
IOAPI_INLINE ( x86, io_to_bus ) ( volatile const void *io_addr ) {
|
||||||
|
return virt_to_phys ( io_addr );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MMIO reads and writes up to 32 bits
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define X86_READX( _api_func, _type ) \
|
||||||
|
static inline __always_inline _type \
|
||||||
|
IOAPI_INLINE ( x86, _api_func ) ( volatile _type *io_addr ) { \
|
||||||
|
return *io_addr; \
|
||||||
|
}
|
||||||
|
X86_READX ( readb, uint8_t );
|
||||||
|
X86_READX ( readw, uint16_t );
|
||||||
|
X86_READX ( readl, uint32_t );
|
||||||
|
|
||||||
|
#define X86_WRITEX( _api_func, _type ) \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( x86, _api_func ) ( _type data, \
|
||||||
|
volatile _type *io_addr ) { \
|
||||||
|
*io_addr = data; \
|
||||||
|
}
|
||||||
|
X86_WRITEX ( writeb, uint8_t );
|
||||||
|
X86_WRITEX ( writew, uint16_t );
|
||||||
|
X86_WRITEX ( writel, uint32_t );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PIO reads and writes up to 32 bits
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define X86_INX( _insn_suffix, _type, _reg_prefix ) \
|
||||||
|
static inline __always_inline _type \
|
||||||
|
IOAPI_INLINE ( x86, in ## _insn_suffix ) ( volatile _type *io_addr ) { \
|
||||||
|
_type data; \
|
||||||
|
__asm__ __volatile__ ( "in" #_insn_suffix " %w1, %" _reg_prefix "0" \
|
||||||
|
: "=a" ( data ) : "Nd" ( io_addr ) ); \
|
||||||
|
return data; \
|
||||||
|
} \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( x86, ins ## _insn_suffix ) ( volatile _type *io_addr, \
|
||||||
|
_type *data, \
|
||||||
|
unsigned int count ) { \
|
||||||
|
unsigned int discard_D; \
|
||||||
|
__asm__ __volatile__ ( "rep ins" #_insn_suffix \
|
||||||
|
: "=D" ( discard_D ) \
|
||||||
|
: "d" ( io_addr ), "c" ( count ), \
|
||||||
|
"0" ( data ) ); \
|
||||||
|
}
|
||||||
|
X86_INX ( b, uint8_t, "b" );
|
||||||
|
X86_INX ( w, uint16_t, "w" );
|
||||||
|
X86_INX ( l, uint32_t, "k" );
|
||||||
|
|
||||||
|
#define X86_OUTX( _insn_suffix, _type, _reg_prefix ) \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( x86, out ## _insn_suffix ) ( _type data, \
|
||||||
|
volatile _type *io_addr ) { \
|
||||||
|
__asm__ __volatile__ ( "out" #_insn_suffix " %" _reg_prefix "0, %w1" \
|
||||||
|
: : "a" ( data ), "Nd" ( io_addr ) ); \
|
||||||
|
} \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( x86, outs ## _insn_suffix ) ( volatile _type *io_addr, \
|
||||||
|
const _type *data, \
|
||||||
|
unsigned int count ) { \
|
||||||
|
unsigned int discard_S; \
|
||||||
|
__asm__ __volatile__ ( "rep outs" #_insn_suffix \
|
||||||
|
: "=S" ( discard_S ) \
|
||||||
|
: "d" ( io_addr ), "c" ( count ), \
|
||||||
|
"0" ( data ) ); \
|
||||||
|
}
|
||||||
|
X86_OUTX ( b, uint8_t, "b" );
|
||||||
|
X86_OUTX ( w, uint16_t, "w" );
|
||||||
|
X86_OUTX ( l, uint32_t, "k" );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Slow down I/O
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline __always_inline void
|
||||||
|
IOAPI_INLINE ( x86, iodelay ) ( void ) {
|
||||||
|
__asm__ __volatile__ ( "outb %al, $0x80" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Memory barrier
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline __always_inline void
|
||||||
|
IOAPI_INLINE ( x86, mb ) ( void ) {
|
||||||
|
__asm__ __volatile__ ( "lock; addl $0, 0(%%esp)" : : : "memory" );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _GPXE_X86_IO_H */
|
||||||
@@ -7,8 +7,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <gpxe/list.h>
|
#include <gpxe/list.h>
|
||||||
|
#include <realmode.h>
|
||||||
|
|
||||||
struct block_device;
|
struct block_device;
|
||||||
|
|
||||||
|
|||||||
@@ -1,265 +0,0 @@
|
|||||||
#ifndef ETHERBOOT_IO_H
|
|
||||||
#define ETHERBOOT_IO_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "virtaddr.h"
|
|
||||||
|
|
||||||
/* virt_to_bus converts an addresss inside of etherboot [_start, _end]
|
|
||||||
* into a memory access cards can use.
|
|
||||||
*/
|
|
||||||
#define virt_to_bus virt_to_phys
|
|
||||||
|
|
||||||
|
|
||||||
/* bus_to_virt reverses virt_to_bus, the address must be output
|
|
||||||
* from virt_to_bus to be valid. This function does not work on
|
|
||||||
* all bus addresses.
|
|
||||||
*/
|
|
||||||
#define bus_to_virt phys_to_virt
|
|
||||||
|
|
||||||
/* ioremap converts a random 32bit bus address into something
|
|
||||||
* etherboot can access.
|
|
||||||
*/
|
|
||||||
static inline void *ioremap(unsigned long bus_addr, unsigned long length __unused)
|
|
||||||
{
|
|
||||||
return bus_to_virt(bus_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* iounmap cleans up anything ioremap had to setup */
|
|
||||||
static inline void iounmap(void *virt_addr __unused)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file contains the definitions for the x86 IO instructions
|
|
||||||
* inb/inw/inl/outb/outw/outl and the "string versions" of the same
|
|
||||||
* (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
|
|
||||||
* versions of the single-IO instructions (inb_p/inw_p/..).
|
|
||||||
*
|
|
||||||
* This file is not meant to be obfuscating: it's just complicated
|
|
||||||
* to (a) handle it all in a way that makes gcc able to optimize it
|
|
||||||
* as well as possible and (b) trying to avoid writing the same thing
|
|
||||||
* over and over again with slight variations and possibly making a
|
|
||||||
* mistake somewhere.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Thanks to James van Artsdalen for a better timing-fix than
|
|
||||||
* the two short jumps: using outb's to a nonexistent port seems
|
|
||||||
* to guarantee better timings even on fast machines.
|
|
||||||
*
|
|
||||||
* On the other hand, I'd like to be sure of a non-existent port:
|
|
||||||
* I feel a bit unsafe about using 0x80 (should be safe, though)
|
|
||||||
*
|
|
||||||
* Linus
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef SLOW_IO_BY_JUMPING
|
|
||||||
#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
|
|
||||||
#else
|
|
||||||
#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef REALLY_SLOW_IO
|
|
||||||
#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
|
|
||||||
#else
|
|
||||||
#define SLOW_DOWN_IO __SLOW_DOWN_IO
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* readX/writeX() are used to access memory mapped devices. On some
|
|
||||||
* architectures the memory mapped IO stuff needs to be accessed
|
|
||||||
* differently. On the x86 architecture, we just read/write the
|
|
||||||
* memory location directly.
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) unsigned long
|
|
||||||
_readb ( volatile uint8_t *addr ) {
|
|
||||||
unsigned long data = *addr;
|
|
||||||
DBGIO ( "[%08lx] => %02lx\n", virt_to_phys ( addr ), data );
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
static inline __attribute__ (( always_inline )) unsigned long
|
|
||||||
_readw ( volatile uint16_t *addr ) {
|
|
||||||
unsigned long data = *addr;
|
|
||||||
DBGIO ( "[%08lx] => %04lx\n", virt_to_phys ( addr ), data );
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
static inline __attribute__ (( always_inline )) unsigned long
|
|
||||||
_readl ( volatile uint32_t *addr ) {
|
|
||||||
unsigned long data = *addr;
|
|
||||||
DBGIO ( "[%08lx] => %08lx\n", virt_to_phys ( addr ), data );
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
#define readb( addr ) _readb ( ( volatile uint8_t * ) (addr) )
|
|
||||||
#define readw( addr ) _readw ( ( volatile uint16_t * ) (addr) )
|
|
||||||
#define readl( addr ) _readl ( ( volatile uint32_t * ) (addr) )
|
|
||||||
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
_writeb ( unsigned long data, volatile uint8_t *addr ) {
|
|
||||||
DBGIO ( "[%08lx] <= %02lx\n", virt_to_phys ( addr ), data );
|
|
||||||
*addr = data;
|
|
||||||
}
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
_writew ( unsigned long data, volatile uint16_t *addr ) {
|
|
||||||
DBGIO ( "[%08lx] <= %04lx\n", virt_to_phys ( addr ), data );
|
|
||||||
*addr = data;
|
|
||||||
}
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
_writel ( unsigned long data, volatile uint32_t *addr ) {
|
|
||||||
DBGIO ( "[%08lx] <= %08lx\n", virt_to_phys ( addr ), data );
|
|
||||||
*addr = data;
|
|
||||||
}
|
|
||||||
#define writeb( b, addr ) _writeb ( (b), ( volatile uint8_t * ) (addr) )
|
|
||||||
#define writew( b, addr ) _writew ( (b), ( volatile uint16_t * ) (addr) )
|
|
||||||
#define writel( b, addr ) _writel ( (b), ( volatile uint32_t * ) (addr) )
|
|
||||||
|
|
||||||
#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
|
|
||||||
#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Force strict CPU ordering.
|
|
||||||
* And yes, this is required on UP too when we're talking
|
|
||||||
* to devices.
|
|
||||||
*
|
|
||||||
* For now, "wmb()" doesn't actually do anything, as all
|
|
||||||
* Intel CPU's follow what Intel calls a *Processor Order*,
|
|
||||||
* in which all writes are seen in the program order even
|
|
||||||
* outside the CPU.
|
|
||||||
*
|
|
||||||
* I expect future Intel CPU's to have a weaker ordering,
|
|
||||||
* but I'd also expect them to finally get their act together
|
|
||||||
* and add some real memory barriers if so.
|
|
||||||
*
|
|
||||||
* Some non intel clones support out of order store. wmb() ceases to be a
|
|
||||||
* nop for these.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
|
|
||||||
#define rmb() mb()
|
|
||||||
#define wmb() mb();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Talk about misusing macros..
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define __OUT1(s,x) \
|
|
||||||
extern void __out##s(unsigned x value, unsigned short port); \
|
|
||||||
extern inline void __out##s(unsigned x value, unsigned short port) {
|
|
||||||
|
|
||||||
#define __OUT2(s,s1,s2) \
|
|
||||||
__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
|
|
||||||
|
|
||||||
#define __OUT(s,s1,x) \
|
|
||||||
__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
|
|
||||||
__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
|
|
||||||
__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
|
|
||||||
__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
|
|
||||||
|
|
||||||
#define __IN1(s,x) \
|
|
||||||
extern unsigned x __in##s(unsigned short port); \
|
|
||||||
extern inline unsigned x __in##s(unsigned short port) { unsigned x _v;
|
|
||||||
|
|
||||||
#define __IN2(s,s1,s2) \
|
|
||||||
__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
|
|
||||||
|
|
||||||
#define __IN(s,s1,x,i...) \
|
|
||||||
__IN1(s,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
|
|
||||||
__IN1(s##c,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
|
|
||||||
__IN1(s##_p,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
|
|
||||||
__IN1(s##c_p,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
|
|
||||||
|
|
||||||
#define __INS(s) \
|
|
||||||
extern void ins##s(unsigned short port, void * addr, unsigned long count); \
|
|
||||||
extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
|
|
||||||
{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
|
|
||||||
: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
|
|
||||||
|
|
||||||
#define __OUTS(s) \
|
|
||||||
extern void outs##s(unsigned short port, const void * addr, unsigned long count); \
|
|
||||||
extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
|
|
||||||
{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
|
|
||||||
: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
|
|
||||||
|
|
||||||
__IN(b,"", char)
|
|
||||||
__IN(w,"",short)
|
|
||||||
__IN(l,"", long)
|
|
||||||
|
|
||||||
__OUT(b,"b",char)
|
|
||||||
__OUT(w,"w",short)
|
|
||||||
__OUT(l,,int)
|
|
||||||
|
|
||||||
__INS(b)
|
|
||||||
__INS(w)
|
|
||||||
__INS(l)
|
|
||||||
|
|
||||||
__OUTS(b)
|
|
||||||
__OUTS(w)
|
|
||||||
__OUTS(l)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Note that due to the way __builtin_constant_p() works, you
|
|
||||||
* - can't use it inside a inline function (it will never be true)
|
|
||||||
* - you don't have to worry about side effects within the __builtin..
|
|
||||||
*/
|
|
||||||
#define outb(val,port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__outbc((val),(port)) : \
|
|
||||||
__outb((val),(port)))
|
|
||||||
|
|
||||||
#define inb(port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__inbc(port) : \
|
|
||||||
__inb(port))
|
|
||||||
|
|
||||||
#define outb_p(val,port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__outbc_p((val),(port)) : \
|
|
||||||
__outb_p((val),(port)))
|
|
||||||
|
|
||||||
#define inb_p(port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__inbc_p(port) : \
|
|
||||||
__inb_p(port))
|
|
||||||
|
|
||||||
#define outw(val,port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__outwc((val),(port)) : \
|
|
||||||
__outw((val),(port)))
|
|
||||||
|
|
||||||
#define inw(port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__inwc(port) : \
|
|
||||||
__inw(port))
|
|
||||||
|
|
||||||
#define outw_p(val,port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__outwc_p((val),(port)) : \
|
|
||||||
__outw_p((val),(port)))
|
|
||||||
|
|
||||||
#define inw_p(port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__inwc_p(port) : \
|
|
||||||
__inw_p(port))
|
|
||||||
|
|
||||||
#define outl(val,port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__outlc((val),(port)) : \
|
|
||||||
__outl((val),(port)))
|
|
||||||
|
|
||||||
#define inl(port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__inlc(port) : \
|
|
||||||
__inl(port))
|
|
||||||
|
|
||||||
#define outl_p(val,port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__outlc_p((val),(port)) : \
|
|
||||||
__outl_p((val),(port)))
|
|
||||||
|
|
||||||
#define inl_p(port) \
|
|
||||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
|
||||||
__inlc_p(port) : \
|
|
||||||
__inl_p(port))
|
|
||||||
|
|
||||||
#endif /* ETHERBOOT_IO_H */
|
|
||||||
Executable → Regular
+100
-205
@@ -1,21 +1,111 @@
|
|||||||
#ifndef LIBRM_H
|
#ifndef LIBRM_H
|
||||||
#define LIBRM_H
|
#define LIBRM_H
|
||||||
|
|
||||||
/* Drag in protected-mode segment selector values */
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#include "virtaddr.h"
|
|
||||||
#include "realmode.h"
|
/* Segment selectors as used in our protected-mode GDTs.
|
||||||
|
*
|
||||||
|
* Don't change these unless you really know what you're doing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define VIRTUAL_CS 0x08
|
||||||
|
#define VIRTUAL_DS 0x10
|
||||||
|
#define PHYSICAL_CS 0x18
|
||||||
|
#define PHYSICAL_DS 0x20
|
||||||
|
#define REAL_CS 0x28
|
||||||
|
#define REAL_DS 0x30
|
||||||
|
#if 0
|
||||||
|
#define LONG_CS 0x38
|
||||||
|
#define LONG_DS 0x40
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ASSEMBLY
|
#ifndef ASSEMBLY
|
||||||
|
|
||||||
#include "stddef.h"
|
#ifdef UACCESS_LIBRM
|
||||||
#include "string.h"
|
#define UACCESS_PREFIX_librm
|
||||||
|
#else
|
||||||
|
#define UACCESS_PREFIX_librm __librm_
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/* Variables in librm.S */
|
||||||
* Data structures and type definitions
|
extern unsigned long virt_offset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert physical address to user pointer
|
||||||
|
*
|
||||||
|
* @v phys_addr Physical address
|
||||||
|
* @ret userptr User pointer
|
||||||
|
*/
|
||||||
|
static inline __always_inline userptr_t
|
||||||
|
UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) {
|
||||||
|
return ( phys_addr - virt_offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert user buffer to physical address
|
||||||
|
*
|
||||||
|
* @v userptr User pointer
|
||||||
|
* @v offset Offset from user pointer
|
||||||
|
* @ret phys_addr Physical address
|
||||||
|
*/
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) {
|
||||||
|
return ( userptr + offset + virt_offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline userptr_t
|
||||||
|
UACCESS_INLINE ( librm, virt_to_user ) ( volatile const void *addr ) {
|
||||||
|
return trivial_virt_to_user ( addr );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline void *
|
||||||
|
UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) {
|
||||||
|
return trivial_user_to_virt ( userptr, offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline userptr_t
|
||||||
|
UACCESS_INLINE ( librm, userptr_add ) ( userptr_t userptr, off_t offset ) {
|
||||||
|
return trivial_userptr_add ( userptr, offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline void
|
||||||
|
UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off,
|
||||||
|
userptr_t src, off_t src_off,
|
||||||
|
size_t len ) {
|
||||||
|
trivial_memcpy_user ( dest, dest_off, src, src_off, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline void
|
||||||
|
UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off,
|
||||||
|
userptr_t src, off_t src_off,
|
||||||
|
size_t len ) {
|
||||||
|
trivial_memmove_user ( dest, dest_off, src, src_off, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline void
|
||||||
|
UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset,
|
||||||
|
int c, size_t len ) {
|
||||||
|
trivial_memset_user ( buffer, offset, c, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline size_t
|
||||||
|
UACCESS_INLINE ( librm, strlen_user ) ( userptr_t buffer, off_t offset ) {
|
||||||
|
return trivial_strlen_user ( buffer, offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline off_t
|
||||||
|
UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset,
|
||||||
|
int c, size_t len ) {
|
||||||
|
return trivial_memchr_user ( buffer, offset, c, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Access to variables in .data16 and .text16
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Access to variables in .data16 and .text16 */
|
|
||||||
extern char *data16;
|
extern char *data16;
|
||||||
extern char *text16;
|
extern char *text16;
|
||||||
|
|
||||||
@@ -72,178 +162,6 @@ extern uint16_t __text16 ( rm_ds );
|
|||||||
*/
|
*/
|
||||||
extern void gateA20_set ( void );
|
extern void gateA20_set ( void );
|
||||||
|
|
||||||
/*
|
|
||||||
* librm_mgmt: functions for manipulating base memory and executing
|
|
||||||
* real-mode code.
|
|
||||||
*
|
|
||||||
* Full API documentation for these functions is in realmode.h.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Macro for obtaining a physical address from a segment:offset pair. */
|
|
||||||
#define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )
|
|
||||||
|
|
||||||
/* Copy to/from base memory */
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
copy_to_real_librm ( unsigned int dest_seg, unsigned int dest_off,
|
|
||||||
void *src, size_t n ) {
|
|
||||||
memcpy ( VIRTUAL ( dest_seg, dest_off ), src, n );
|
|
||||||
}
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
copy_from_real_librm ( void *dest, unsigned int src_seg,
|
|
||||||
unsigned int src_off, size_t n ) {
|
|
||||||
memcpy ( dest, VIRTUAL ( src_seg, src_off ), n );
|
|
||||||
}
|
|
||||||
#define put_real_librm( var, dest_seg, dest_off ) \
|
|
||||||
do { \
|
|
||||||
* ( ( typeof(var) * ) VIRTUAL ( dest_seg, dest_off ) ) = var; \
|
|
||||||
} while ( 0 )
|
|
||||||
#define get_real_librm( var, src_seg, src_off ) \
|
|
||||||
do { \
|
|
||||||
var = * ( ( typeof(var) * ) VIRTUAL ( src_seg, src_off ) ); \
|
|
||||||
} while ( 0 )
|
|
||||||
#define copy_to_real copy_to_real_librm
|
|
||||||
#define copy_from_real copy_from_real_librm
|
|
||||||
#define put_real put_real_librm
|
|
||||||
#define get_real get_real_librm
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A pointer to a user buffer
|
|
||||||
*
|
|
||||||
* Even though we could just use a void *, we use an intptr_t so that
|
|
||||||
* attempts to use normal pointers show up as compiler warnings. Such
|
|
||||||
* code is actually valid for librm, but not for libkir (i.e. under
|
|
||||||
* KEEP_IT_REAL), so it's good to have the warnings even under librm.
|
|
||||||
*/
|
|
||||||
typedef intptr_t userptr_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add offset to user pointer
|
|
||||||
*
|
|
||||||
* @v ptr User pointer
|
|
||||||
* @v offset Offset
|
|
||||||
* @ret new_ptr New pointer value
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) userptr_t
|
|
||||||
userptr_add ( userptr_t ptr, off_t offset ) {
|
|
||||||
return ( ptr + offset );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy data to user buffer
|
|
||||||
*
|
|
||||||
* @v buffer User buffer
|
|
||||||
* @v offset Offset within user buffer
|
|
||||||
* @v src Source
|
|
||||||
* @v len Length
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
copy_to_user ( userptr_t buffer, off_t offset, const void *src, size_t len ) {
|
|
||||||
memcpy ( ( ( void * ) buffer + offset ), src, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy data from user buffer
|
|
||||||
*
|
|
||||||
* @v dest Destination
|
|
||||||
* @v buffer User buffer
|
|
||||||
* @v offset Offset within user buffer
|
|
||||||
* @v len Length
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
copy_from_user ( void *dest, userptr_t buffer, off_t offset, size_t len ) {
|
|
||||||
memcpy ( dest, ( ( void * ) buffer + offset ), len );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy data between user buffers
|
|
||||||
*
|
|
||||||
* @v dest Destination user buffer
|
|
||||||
* @v dest_off Offset within destination buffer
|
|
||||||
* @v src Source user buffer
|
|
||||||
* @v src_off Offset within source buffer
|
|
||||||
* @v len Length
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
memcpy_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
|
|
||||||
size_t len ) {
|
|
||||||
memcpy ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
|
|
||||||
len );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy data between user buffers, allowing for overlap
|
|
||||||
*
|
|
||||||
* @v dest Destination user buffer
|
|
||||||
* @v dest_off Offset within destination buffer
|
|
||||||
* @v src Source user buffer
|
|
||||||
* @v src_off Offset within source buffer
|
|
||||||
* @v len Length
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
memmove_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
|
|
||||||
size_t len ) {
|
|
||||||
memmove ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
|
|
||||||
len );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fill user buffer with a constant byte
|
|
||||||
*
|
|
||||||
* @v buffer User buffer
|
|
||||||
* @v offset Offset within buffer
|
|
||||||
* @v c Constant byte with which to fill
|
|
||||||
* @v len Length
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) void
|
|
||||||
memset_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
|
|
||||||
memset ( ( ( void * ) buffer + offset ), c, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find length of NUL-terminated string in user buffer
|
|
||||||
*
|
|
||||||
* @v buffer User buffer
|
|
||||||
* @v offset Offset within buffer
|
|
||||||
* @ret len Length of string (excluding NUL)
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) size_t
|
|
||||||
strlen_user ( userptr_t buffer, off_t offset ) {
|
|
||||||
return strlen ( ( void * ) buffer + offset );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find character in user buffer
|
|
||||||
*
|
|
||||||
* @v buffer User buffer
|
|
||||||
* @v offset Starting offset within buffer
|
|
||||||
* @v c Character to search for
|
|
||||||
* @v len Length of user buffer
|
|
||||||
* @ret offset Offset of character, or <0 if not found
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) off_t
|
|
||||||
memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
|
|
||||||
void *found;
|
|
||||||
|
|
||||||
found = memchr ( ( ( void * ) buffer + offset ), c, len );
|
|
||||||
return ( found ? ( found - ( void * ) buffer ) : -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert virtual address to user buffer
|
|
||||||
*
|
|
||||||
* @v virtual Virtual address
|
|
||||||
* @ret buffer User buffer
|
|
||||||
*
|
|
||||||
* This constructs a user buffer from an ordinary pointer. Use it
|
|
||||||
* when you need to pass a pointer to an internal buffer to a function
|
|
||||||
* that expects a @c userptr_t.
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) userptr_t
|
|
||||||
virt_to_user ( void * virtual ) {
|
|
||||||
return ( ( intptr_t ) virtual );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert segment:offset address to user buffer
|
* Convert segment:offset address to user buffer
|
||||||
*
|
*
|
||||||
@@ -251,32 +169,9 @@ virt_to_user ( void * virtual ) {
|
|||||||
* @v offset Real-mode offset
|
* @v offset Real-mode offset
|
||||||
* @ret buffer User buffer
|
* @ret buffer User buffer
|
||||||
*/
|
*/
|
||||||
static inline __attribute__ (( always_inline )) userptr_t
|
static inline __always_inline userptr_t
|
||||||
real_to_user ( unsigned int segment, unsigned int offset ) {
|
real_to_user ( unsigned int segment, unsigned int offset ) {
|
||||||
return virt_to_user ( VIRTUAL ( segment, offset ) );
|
return ( phys_to_user ( ( segment << 4 ) + offset ) );
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert physical address to user buffer
|
|
||||||
*
|
|
||||||
* @v physical Physical address
|
|
||||||
* @ret buffer User buffer
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) userptr_t
|
|
||||||
phys_to_user ( physaddr_t physical ) {
|
|
||||||
return virt_to_user ( phys_to_virt ( physical ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert user buffer to physical address
|
|
||||||
*
|
|
||||||
* @v buffer User buffer
|
|
||||||
* @v offset Offset within user buffer
|
|
||||||
* @ret physical Physical address
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) physaddr_t
|
|
||||||
user_to_phys ( userptr_t buffer, off_t offset ) {
|
|
||||||
return virt_to_phys ( ( void * ) buffer + offset );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size );
|
extern uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size );
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef LIMITS_H
|
#ifndef LIMITS_H
|
||||||
#define LIMITS_H 1
|
#define LIMITS_H 1
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
/* Number of bits in a `char' */
|
/* Number of bits in a `char' */
|
||||||
#define CHAR_BIT 8
|
#define CHAR_BIT 8
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef _MEMSIZES_H
|
#ifndef _MEMSIZES_H
|
||||||
#define _MEMSIZES_H
|
#define _MEMSIZES_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#include <basemem.h>
|
#include <basemem.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user