|
Lines 242-256
Link Here
|
| 242 |
colon to the message.</para> |
242 |
colon to the message.</para> |
| 243 |
|
243 |
|
| 244 |
<para>The device_t methods are implemented in the file |
244 |
<para>The device_t methods are implemented in the file |
| 245 |
kern/bus_subr.c.</para> |
245 |
<filename>kern/bus_subr.c</filename>.</para> |
| 246 |
|
246 |
|
| 247 |
</sect1> |
247 |
</sect1> |
| 248 |
|
248 |
|
| 249 |
<sect1> |
249 |
<sect1> |
| 250 |
<title>Config file and the order of identifying and probing |
250 |
<title>Configuration file and the order of identifying and probing |
| 251 |
during auto-configuration</title> |
251 |
during auto-configuration</title> |
| 252 |
|
252 |
|
| 253 |
<para>The ISA devices are described in the kernel config file |
253 |
<para>The ISA devices are described in the kernel configuration file |
| 254 |
like:</para> |
254 |
like:</para> |
| 255 |
|
255 |
|
| 256 |
<programlisting>device xxx0 at isa? port 0x300 irq 10 drq 5 |
256 |
<programlisting>device xxx0 at isa? port 0x300 irq 10 drq 5 |
|
Lines 258-264
Link Here
|
| 258 |
|
258 |
|
| 259 |
<para>The values of port, IRQ and so on are converted to the |
259 |
<para>The values of port, IRQ and so on are converted to the |
| 260 |
resource values associated with the device. They are optional, |
260 |
resource values associated with the device. They are optional, |
| 261 |
depending on the device needs and abilities for |
261 |
depending on the device's needs and abilities for |
| 262 |
auto-configuration. For example, some devices do not need DRQ |
262 |
auto-configuration. For example, some devices do not need DRQ |
| 263 |
at all and some allow the driver to read the IRQ setting from |
263 |
at all and some allow the driver to read the IRQ setting from |
| 264 |
the device configuration ports. If a machine has multiple ISA |
264 |
the device configuration ports. If a machine has multiple ISA |
|
Lines 266-272
Link Here
|
| 266 |
line, like "isa0" or "isa1", otherwise the device would be |
266 |
line, like "isa0" or "isa1", otherwise the device would be |
| 267 |
searched for on all the ISA buses.</para> |
267 |
searched for on all the ISA buses.</para> |
| 268 |
|
268 |
|
| 269 |
<para>"sensitive" is a resource requesting that this device must |
269 |
<para><quote>sensitive</quote> is a resource requesting that this device must |
| 270 |
be probed before all non-sensitive devices. It is supported |
270 |
be probed before all non-sensitive devices. It is supported |
| 271 |
but does not seem to be used in any current driver.</para> |
271 |
but does not seem to be used in any current driver.</para> |
| 272 |
|
272 |
|
|
Lines 307-313
Link Here
|
| 307 |
prevent them from being probed as legacy devices.</para> |
307 |
prevent them from being probed as legacy devices.</para> |
| 308 |
|
308 |
|
| 309 |
<para>The probe routines of non-PnP devices marked as |
309 |
<para>The probe routines of non-PnP devices marked as |
| 310 |
"sensitive" are called. If probe for a device went |
310 |
<quote>sensitive</quote> are called. If a probe for a device went |
| 311 |
successfully, the attach routine is called for it.</para> |
311 |
successfully, the attach routine is called for it.</para> |
| 312 |
|
312 |
|
| 313 |
<para>The probe and attach routines of all non-PNP devices are |
313 |
<para>The probe and attach routines of all non-PNP devices are |
|
Lines 321-327
Link Here
|
| 321 |
<para>Then for each PnP device the probe routines of all the |
321 |
<para>Then for each PnP device the probe routines of all the |
| 322 |
present ISA drivers are called. The first one that claims the |
322 |
present ISA drivers are called. The first one that claims the |
| 323 |
device gets attached. It is possible that multiple drivers |
323 |
device gets attached. It is possible that multiple drivers |
| 324 |
would claim the device with different priority, the |
324 |
would claim the device with different priority; in this case, the |
| 325 |
highest-priority driver wins. The probe routines must call |
325 |
highest-priority driver wins. The probe routines must call |
| 326 |
<function>ISA_PNP_PROBE()</function> to compare the actual PnP |
326 |
<function>ISA_PNP_PROBE()</function> to compare the actual PnP |
| 327 |
ID with the list of the IDs supported by the driver and if the |
327 |
ID with the list of the IDs supported by the driver and if the |
|
Lines 375-382
Link Here
|
| 375 |
accessing the configuration resources directly with functions |
375 |
accessing the configuration resources directly with functions |
| 376 |
of families <function>resource_query_*()</function> and |
376 |
of families <function>resource_query_*()</function> and |
| 377 |
<function>resource_*_value()</function>. Their implementations |
377 |
<function>resource_*_value()</function>. Their implementations |
| 378 |
are located in kern/subr_bus.h. The old IDE disk driver |
378 |
are located in <filename>kern/subr_bus.h</filename>. The old IDE disk driver |
| 379 |
i386/isa/wd.c contains examples of such use. But the standard |
379 |
<filename>i386/isa/wd.c</filename> contains examples of such use. But the standard |
| 380 |
means of configuration must always be preferred. Leave parsing |
380 |
means of configuration must always be preferred. Leave parsing |
| 381 |
the configuration resources to the bus configuration |
381 |
the configuration resources to the bus configuration |
| 382 |
code.</para> |
382 |
code.</para> |
|
Lines 393-400
Link Here
|
| 393 |
device_t and the bus resources associated with it. The drivers |
393 |
device_t and the bus resources associated with it. The drivers |
| 394 |
may access the configuration resources directly using |
394 |
may access the configuration resources directly using |
| 395 |
functions resource_* for more complex cases of |
395 |
functions resource_* for more complex cases of |
| 396 |
configuration. But generally it is not needed nor recommended, |
396 |
configuration. However, generally this is neither needed nor recommended, |
| 397 |
so this issue is not discussed further.</para> |
397 |
so this issue is not discussed further here.</para> |
| 398 |
|
398 |
|
| 399 |
<para>The bus resources are associated with each device. They |
399 |
<para>The bus resources are associated with each device. They |
| 400 |
are identified by type and number within the type. For the ISA |
400 |
are identified by type and number within the type. For the ISA |
|
Lines 424-435
Link Here
|
| 424 |
</itemizedlist> |
424 |
</itemizedlist> |
| 425 |
|
425 |
|
| 426 |
<para>The enumeration within types starts from 0, so if a device |
426 |
<para>The enumeration within types starts from 0, so if a device |
| 427 |
has two memory regions if would have resources of type |
427 |
has two memory regions it would have resources of type |
| 428 |
SYS_RES_MEMORY numbered 0 and 1. The resource type has |
428 |
SYS_RES_MEMORY numbered 0 and 1. The resource type has |
| 429 |
nothing to do with the C language type, all the resource |
429 |
nothing to do with the C language type, all the resource |
| 430 |
values have the C language type "unsigned long" and must be |
430 |
values have the C language type "unsigned long" and must be |
| 431 |
cast as necessary. The resource numbers do not have to be |
431 |
cast as necessary. The resource numbers do not have to be |
| 432 |
contiguous although for ISA they normally would be. The |
432 |
contiguous, although for ISA they normally would be. The |
| 433 |
permitted resource numbers for ISA devices are:</para> |
433 |
permitted resource numbers for ISA devices are:</para> |
| 434 |
|
434 |
|
| 435 |
<programlisting> IRQ: 0-1 |
435 |
<programlisting> IRQ: 0-1 |
|
Lines 438-445
Link Here
|
| 438 |
IOPORT: 0-7</programlisting> |
438 |
IOPORT: 0-7</programlisting> |
| 439 |
|
439 |
|
| 440 |
<para>All the resources are represented as ranges, with a start |
440 |
<para>All the resources are represented as ranges, with a start |
| 441 |
value and count. For IRQ and DRQ resources the count would be |
441 |
value and count. For IRQ and DRQ resources the count would |
| 442 |
normally equal to 1. The values for memory refer to the |
442 |
normally be equal to 1. The values for memory refer to the |
| 443 |
physical addresses.</para> |
443 |
physical addresses.</para> |
| 444 |
|
444 |
|
| 445 |
<para>Three types of activities can be performed on |
445 |
<para>Three types of activities can be performed on |
|
Lines 455-461
Link Here
|
| 455 |
reserves the requested range that no other driver would be |
455 |
reserves the requested range that no other driver would be |
| 456 |
able to reserve it (and checking that no other driver reserved |
456 |
able to reserve it (and checking that no other driver reserved |
| 457 |
this range already). Activation makes the resource accessible |
457 |
this range already). Activation makes the resource accessible |
| 458 |
to the driver doing whatever is necessary for that (for |
458 |
to the driver by doing whatever is necessary for that (for |
| 459 |
example, for memory it would be mapping into the kernel |
459 |
example, for memory it would be mapping into the kernel |
| 460 |
virtual address space).</para> |
460 |
virtual address space).</para> |
| 461 |
|
461 |
|
|
Lines 468-475
Link Here
|
| 468 |
|
468 |
|
| 469 |
<para>Set a range for a resource. Returns 0 if successful, |
469 |
<para>Set a range for a resource. Returns 0 if successful, |
| 470 |
error code otherwise. Normally the only reason this |
470 |
error code otherwise. Normally the only reason this |
| 471 |
function would return an error is value of type, rid, |
471 |
function would return an error is if the value of type, rid, |
| 472 |
start or count out of permitted range.</para> |
472 |
start or count were out of permitted range.</para> |
| 473 |
|
473 |
|
| 474 |
<itemizedlist> |
474 |
<itemizedlist> |
| 475 |
<listitem> |
475 |
<listitem> |
|
Lines 505-511
Link Here
|
| 505 |
has 0 among the legitimate values it would be impossible |
505 |
has 0 among the legitimate values it would be impossible |
| 506 |
to tell if the value is 0 or an error occurred. Luckily, |
506 |
to tell if the value is 0 or an error occurred. Luckily, |
| 507 |
no ISA resources for add-on drivers may have a start value |
507 |
no ISA resources for add-on drivers may have a start value |
| 508 |
equal 0.</para> |
508 |
equal to 0.</para> |
| 509 |
</listitem> |
509 |
</listitem> |
| 510 |
|
510 |
|
| 511 |
<listitem> |
511 |
<listitem> |
|
Lines 671-677
Link Here
|
| 671 |
</listitem> |
671 |
</listitem> |
| 672 |
</itemizedlist> |
672 |
</itemizedlist> |
| 673 |
|
673 |
|
| 674 |
<para>A number of methods is defined to operate on the resource |
674 |
<para>A number of methods are defined to operate on the resource |
| 675 |
handlers (struct resource *). Those of interest to the device |
675 |
handlers (struct resource *). Those of interest to the device |
| 676 |
driver writers are:</para> |
676 |
driver writers are:</para> |
| 677 |
|
677 |
|
|
Lines 696-704
Link Here
|
| 696 |
device through the memory. Two variants are possible:</para> |
696 |
device through the memory. Two variants are possible:</para> |
| 697 |
|
697 |
|
| 698 |
<para>(a) memory is located on the device card</para> |
698 |
<para>(a) memory is located on the device card</para> |
| 699 |
<para>(b) memory is the main memory of computer</para> |
699 |
<para>(b) memory is the main memory of the computer</para> |
| 700 |
|
700 |
|
| 701 |
<para>In the case (a) the driver always copies the data back and |
701 |
<para>In case (a) the driver always copies the data back and |
| 702 |
forth between the on-card memory and the main memory as |
702 |
forth between the on-card memory and the main memory as |
| 703 |
necessary. To map the on-card memory into the kernel virtual |
703 |
necessary. To map the on-card memory into the kernel virtual |
| 704 |
address space the physical address and length of the on-card |
704 |
address space the physical address and length of the on-card |
|
Lines 717-729
Link Here
|
| 717 |
limitation on the ISA bus). In that case if the machine has |
717 |
limitation on the ISA bus). In that case if the machine has |
| 718 |
more memory than the start address of the device memory (in |
718 |
more memory than the start address of the device memory (in |
| 719 |
other words, they overlap) a memory hole must be configured at |
719 |
other words, they overlap) a memory hole must be configured at |
| 720 |
the address range used by devices. Many BIOSes allow to |
720 |
the address range used by devices. Many BIOSes allow |
| 721 |
configure a memory hole of 1MB starting at 14MB or |
721 |
configuration of a memory hole of 1MB starting at 14MB or |
| 722 |
15MB. FreeBSD can handle the memory holes properly if the BIOS |
722 |
15MB. FreeBSD can handle the memory holes properly if the BIOS |
| 723 |
reports them properly (old BIOSes may have this feature |
723 |
reports them properly (this feature may be broken on old BIOSes).</para> |
| 724 |
broken).</para> |
|
|
| 725 |
|
724 |
|
| 726 |
<para>In the case (b) just the address of the data is sent to |
725 |
<para>In case (b) just the address of the data is sent to |
| 727 |
the device, and the device uses DMA to actually access the |
726 |
the device, and the device uses DMA to actually access the |
| 728 |
data in the main memory. Two limitations are present: First, |
727 |
data in the main memory. Two limitations are present: First, |
| 729 |
ISA cards can only access memory below 16MB. Second, the |
728 |
ISA cards can only access memory below 16MB. Second, the |
|
Lines 741-747
Link Here
|
| 741 |
|
740 |
|
| 742 |
<para>Tags are organized into a tree-like hierarchy with |
741 |
<para>Tags are organized into a tree-like hierarchy with |
| 743 |
inheritance of the properties. A child tag inherits all the |
742 |
inheritance of the properties. A child tag inherits all the |
| 744 |
requirements of its parent tag or may make them more strict |
743 |
requirements of its parent tag, and may make them more strict |
| 745 |
but never more loose.</para> |
744 |
but never more loose.</para> |
| 746 |
|
745 |
|
| 747 |
<para>Normally one top-level tag (with no parent) is created for |
746 |
<para>Normally one top-level tag (with no parent) is created for |
|
Lines 770-776
Link Here
|
| 770 |
reading the data would go from the device to the bounce pages |
769 |
reading the data would go from the device to the bounce pages |
| 771 |
and then copied to their non-conformant original pages. The |
770 |
and then copied to their non-conformant original pages. The |
| 772 |
process of copying between the original and bounce pages is |
771 |
process of copying between the original and bounce pages is |
| 773 |
called synchronization. This is normally used on per-transfer |
772 |
called synchronization. This is normally used on a per-transfer |
| 774 |
basis: buffer for each transfer would be loaded, transfer done |
773 |
basis: buffer for each transfer would be loaded, transfer done |
| 775 |
and buffer unloaded.</para> |
774 |
and buffer unloaded.</para> |
| 776 |
|
775 |
|
|
Lines 795-802
Link Here
|
| 795 |
allocated for this tag. Use value 1 for "no specific |
794 |
allocated for this tag. Use value 1 for "no specific |
| 796 |
alignment". Applies only to the future |
795 |
alignment". Applies only to the future |
| 797 |
<function>bus_dmamem_alloc()</function> but not |
796 |
<function>bus_dmamem_alloc()</function> but not |
| 798 |
<function>bus_dmamap_create()</function> calls. |
797 |
<function>bus_dmamap_create()</function> calls.</para> |
| 799 |
<emphasis>boundary</emphasis> - physical address |
798 |
</listitem> |
|
|
799 |
|
| 800 |
<listitem> |
| 801 |
<para><emphasis>boundary</emphasis> - physical address |
| 800 |
boundary that must not be crossed when allocating the |
802 |
boundary that must not be crossed when allocating the |
| 801 |
memory. Use value 0 for "no boundary". Applies only to |
803 |
memory. Use value 0 for "no boundary". Applies only to |
| 802 |
the future <function>bus_dmamem_alloc()</function> but |
804 |
the future <function>bus_dmamem_alloc()</function> but |
|
Lines 811-817
Link Here
|
| 811 |
|
813 |
|
| 812 |
<listitem> |
814 |
<listitem> |
| 813 |
<para><emphasis>lowaddr, highaddr</emphasis> - the names |
815 |
<para><emphasis>lowaddr, highaddr</emphasis> - the names |
| 814 |
are slighlty misleading; these values are used to limit |
816 |
are slightly misleading; these values are used to limit |
| 815 |
the permitted range of physical addresses used to |
817 |
the permitted range of physical addresses used to |
| 816 |
allocate the memory. The exact meaning varies depending |
818 |
allocate the memory. The exact meaning varies depending |
| 817 |
on the planned future use:</para> |
819 |
on the planned future use:</para> |
|
Lines 853-859
Link Here
|
| 853 |
[lowaddr; highaddr] is passed to the filter function |
855 |
[lowaddr; highaddr] is passed to the filter function |
| 854 |
which decides if it is accessible. The prototype of the |
856 |
which decides if it is accessible. The prototype of the |
| 855 |
filter function is: <function>int filterfunc(void *arg, |
857 |
filter function is: <function>int filterfunc(void *arg, |
| 856 |
bus_addr_t paddr)</function> It must return 0 if the |
858 |
bus_addr_t paddr)</function>. It must return 0 if the |
| 857 |
page is accessible, non-zero otherwise.</para> |
859 |
page is accessible, non-zero otherwise.</para> |
| 858 |
</listitem> |
860 |
</listitem> |
| 859 |
|
861 |
|
|
Lines 875-883
Link Here
|
| 875 |
BUS_SPACE_UNRESTRICTED may not be used to actually load |
877 |
BUS_SPACE_UNRESTRICTED may not be used to actually load |
| 876 |
maps, they may be used only as parent tags. The |
878 |
maps, they may be used only as parent tags. The |
| 877 |
practical limit for nsegments seems to be about 250-300, |
879 |
practical limit for nsegments seems to be about 250-300, |
| 878 |
higher values will cause kernel stack overflow. But |
880 |
higher values will cause kernel stack overflow (the hardware |
| 879 |
anyway the hardware normally can not support that many |
881 |
can not normally support that many |
| 880 |
scatter-gather buffers.</para> |
882 |
scatter-gather buffers anyway).</para> |
| 881 |
</listitem> |
883 |
</listitem> |
| 882 |
|
884 |
|
| 883 |
<listitem> |
885 |
<listitem> |
|
Lines 895-901
Link Here
|
| 895 |
<listitem> |
897 |
<listitem> |
| 896 |
<para><emphasis>BUS_DMA_ALLOCNOW</emphasis> - requests |
898 |
<para><emphasis>BUS_DMA_ALLOCNOW</emphasis> - requests |
| 897 |
to allocate all the potentially needed bounce pages |
899 |
to allocate all the potentially needed bounce pages |
| 898 |
when creating the tag</para> |
900 |
when creating the tag.</para> |
| 899 |
</listitem> |
901 |
</listitem> |
| 900 |
|
902 |
|
| 901 |
<listitem> |
903 |
<listitem> |
|
Lines 910-916
Link Here
|
| 910 |
|
912 |
|
| 911 |
<listitem> |
913 |
<listitem> |
| 912 |
<para><emphasis>dmat</emphasis> - pointer to the storage |
914 |
<para><emphasis>dmat</emphasis> - pointer to the storage |
| 913 |
for the new tag to be returned</para> |
915 |
for the new tag to be returned.</para> |
| 914 |
</listitem> |
916 |
</listitem> |
| 915 |
|
917 |
|
| 916 |
</itemizedlist> |
918 |
</itemizedlist> |
|
Lines 924-930
Link Here
|
| 924 |
<para>Destroy a tag. Returns 0 on success, the error code |
926 |
<para>Destroy a tag. Returns 0 on success, the error code |
| 925 |
otherwise.</para> |
927 |
otherwise.</para> |
| 926 |
|
928 |
|
| 927 |
<para>dmat - the tag to be destroyed</para> |
929 |
<para>dmat - the tag to be destroyed.</para> |
| 928 |
|
930 |
|
| 929 |
</listitem> |
931 |
</listitem> |
| 930 |
|
932 |
|
|
Lines 937-943
Link Here
|
| 937 |
tag. The size of memory to be allocated is tag's maxsize. |
939 |
tag. The size of memory to be allocated is tag's maxsize. |
| 938 |
Returns 0 on success, the error code otherwise. The result |
940 |
Returns 0 on success, the error code otherwise. The result |
| 939 |
still has to be loaded by |
941 |
still has to be loaded by |
| 940 |
<function>bus_dmamap_load()</function> before used to get |
942 |
<function>bus_dmamap_load()</function> before being used to get |
| 941 |
the physical address of the memory.</para> |
943 |
the physical address of the memory.</para> |
| 942 |
|
944 |
|
| 943 |
<!-- XXX What it is Wylie, I got to here --> |
945 |
<!-- XXX What it is Wylie, I got to here --> |
|
Lines 965-972
Link Here
|
| 965 |
<emphasis>BUS_DMA_NOWAIT</emphasis> - if the |
967 |
<emphasis>BUS_DMA_NOWAIT</emphasis> - if the |
| 966 |
memory is not immediately available return the |
968 |
memory is not immediately available return the |
| 967 |
error. If this flag is not set then the routine |
969 |
error. If this flag is not set then the routine |
| 968 |
is allowed to sleep waiting until the memory |
970 |
is allowed to sleep until the memory |
| 969 |
will become available. |
971 |
becomes available. |
| 970 |
</para> |
972 |
</para> |
| 971 |
</listitem> |
973 |
</listitem> |
| 972 |
</itemizedlist> |
974 |
</itemizedlist> |
|
Lines 974-980
Link Here
|
| 974 |
<listitem> |
976 |
<listitem> |
| 975 |
<para> |
977 |
<para> |
| 976 |
<emphasis>mapp</emphasis> - pointer to the storage |
978 |
<emphasis>mapp</emphasis> - pointer to the storage |
| 977 |
for the new map to be returned |
979 |
for the new map to be returned. |
| 978 |
</para> |
980 |
</para> |
| 979 |
</listitem> |
981 |
</listitem> |
| 980 |
</itemizedlist> |
982 |
</itemizedlist> |
|
Lines 987-993
Link Here
|
| 987 |
</para> |
989 |
</para> |
| 988 |
<para> |
990 |
<para> |
| 989 |
Free the memory allocated by |
991 |
Free the memory allocated by |
| 990 |
<function>bus_dmamem_alloc()</function>. As of now |
992 |
<function>bus_dmamem_alloc()</function>. At present, |
| 991 |
freeing of the memory allocated with ISA restrictions is |
993 |
freeing of the memory allocated with ISA restrictions is |
| 992 |
not implemented. Because of this the recommended model |
994 |
not implemented. Because of this the recommended model |
| 993 |
of use is to keep and re-use the allocated areas for as |
995 |
of use is to keep and re-use the allocated areas for as |
|
Lines 1038-1044
Link Here
|
| 1038 |
<listitem> |
1040 |
<listitem> |
| 1039 |
<para> |
1041 |
<para> |
| 1040 |
<emphasis>flags</emphasis> - theoretically, a bit map |
1042 |
<emphasis>flags</emphasis> - theoretically, a bit map |
| 1041 |
of flags. But no flags are defined yet, so as of now |
1043 |
of flags. But no flags are defined yet, so at present |
| 1042 |
it will be always 0. |
1044 |
it will be always 0. |
| 1043 |
</para> |
1045 |
</para> |
| 1044 |
</listitem> |
1046 |
</listitem> |
|
Lines 1532-1538
Link Here
|
| 1532 |
<para> |
1534 |
<para> |
| 1533 |
Release a previously reserved DMA channel. No |
1535 |
Release a previously reserved DMA channel. No |
| 1534 |
transfers must be in progress when the channel is |
1536 |
transfers must be in progress when the channel is |
| 1535 |
released (as well as the device must not try to |
1537 |
released (in addition the device must not try to |
| 1536 |
initiate transfer after the channel is released). |
1538 |
initiate transfer after the channel is released). |
| 1537 |
</para> |
1539 |
</para> |
| 1538 |
</listitem> |
1540 |
</listitem> |
|
Lines 1682-1689
Link Here
|
| 1682 |
will be automatically reset back to the length of |
1684 |
will be automatically reset back to the length of |
| 1683 |
buffer. The normal use is to check the number of bytes |
1685 |
buffer. The normal use is to check the number of bytes |
| 1684 |
left after the device signals that the transfer is |
1686 |
left after the device signals that the transfer is |
| 1685 |
completed. If the number of bytes is not 0 then probably |
1687 |
completed. If the number of bytes is not 0 then something |
| 1686 |
something went wrong with that transfer. |
1688 |
probably went wrong with that transfer. |
| 1687 |
</para> |
1689 |
</para> |
| 1688 |
</listitem> |
1690 |
</listitem> |
| 1689 |
|
1691 |
|
|
Lines 1753-1760
Link Here
|
| 1753 |
resources before returning and if necessary allocate them |
1755 |
resources before returning and if necessary allocate them |
| 1754 |
again in the attach routine. When |
1756 |
again in the attach routine. When |
| 1755 |
<function>xxx_isa_probe()</function> returns 0 releasing the |
1757 |
<function>xxx_isa_probe()</function> returns 0 releasing the |
| 1756 |
resources before returning is also a good idea, a |
1758 |
resources before returning is also a good idea and a |
| 1757 |
well-behaved driver should do so. But in case if there is |
1759 |
well-behaved driver should do so. But in cases where there is |
| 1758 |
some problem with releasing the resources the driver is |
1760 |
some problem with releasing the resources the driver is |
| 1759 |
allowed to keep resources between returning 0 from the probe |
1761 |
allowed to keep resources between returning 0 from the probe |
| 1760 |
routine and execution of the attach routine. |
1762 |
routine and execution of the attach routine. |
|
Lines 1895-1902
Link Here
|
| 1895 |
better to be done in <function>probe()</function>: if this |
1897 |
better to be done in <function>probe()</function>: if this |
| 1896 |
probe would drive some other sensitive device crazy. The |
1898 |
probe would drive some other sensitive device crazy. The |
| 1897 |
probe routines are ordered with consideration of the |
1899 |
probe routines are ordered with consideration of the |
| 1898 |
"sensitive" flag: the sensitive devices get probed first and |
1900 |
<quote>sensitive</quote> flag: the sensitive devices get probed first and |
| 1899 |
the rest of devices later. But the |
1901 |
the other devices later. But the |
| 1900 |
<function>identify()</function> routines are called before |
1902 |
<function>identify()</function> routines are called before |
| 1901 |
any probes, so they show no respect to the sensitive devices |
1903 |
any probes, so they show no respect to the sensitive devices |
| 1902 |
and may upset them. |
1904 |
and may upset them. |
|
Lines 2201-2207
Link Here
|
| 2201 |
the convention suggests passing the pointer to structure |
2203 |
the convention suggests passing the pointer to structure |
| 2202 |
softc. The important reason is that when the structures |
2204 |
softc. The important reason is that when the structures |
| 2203 |
softc are allocated dynamically then getting the unit number |
2205 |
softc are allocated dynamically then getting the unit number |
| 2204 |
from softc is easy while getting softc from unit number is |
2206 |
from softc is easy while getting softc from the unit number is |
| 2205 |
difficult. Also this convention makes the drivers for |
2207 |
difficult. Also this convention makes the drivers for |
| 2206 |
different buses look more uniform and allows them to share |
2208 |
different buses look more uniform and allows them to share |
| 2207 |
the code: each bus gets its own probe, attach, detach and |
2209 |
the code: each bus gets its own probe, attach, detach and |
|
Lines 2349-2362
Link Here
|
| 2349 |
the ISA devices. The ability to unload a driver may be |
2351 |
the ISA devices. The ability to unload a driver may be |
| 2350 |
useful when debugging it, but in many cases installation of |
2352 |
useful when debugging it, but in many cases installation of |
| 2351 |
the new version of the driver would be required only after |
2353 |
the new version of the driver would be required only after |
| 2352 |
the old version somehow wedges the system and reboot will be |
2354 |
the old version somehow wedges the system and a reboot will be |
| 2353 |
needed anyway, so the efforts spent on writing the detach |
2355 |
needed anyway, so the efforts spent on writing the detach |
| 2354 |
routine may not be worth it. Another argument is that |
2356 |
routine may not be worth it. Another argument that |
| 2355 |
unloading would allow upgrading the drivers on a production |
2357 |
unloading would allow upgrading the drivers on a production |
| 2356 |
machine seems to be mostly theoretical. Installing a new |
2358 |
machine seems to be mostly theoretical. Installing a new |
| 2357 |
version of a driver is a dangerous operation which should |
2359 |
version of a driver is a dangerous operation which should |
| 2358 |
never be performed on a production machine (and which is not |
2360 |
never be performed on a production machine (and which is not |
| 2359 |
permitted when the system is running in secure mode). Still |
2361 |
permitted when the system is running in secure mode). Still, |
| 2360 |
the detach routine may be provided for the sake of |
2362 |
the detach routine may be provided for the sake of |
| 2361 |
completeness. |
2363 |
completeness. |
| 2362 |
</para> |
2364 |
</para> |
|
Lines 2388-2394
Link Here
|
| 2388 |
transfers, disabling the DMA channels and interrupts to |
2390 |
transfers, disabling the DMA channels and interrupts to |
| 2389 |
avoid memory corruption by the device. For most of the |
2391 |
avoid memory corruption by the device. For most of the |
| 2390 |
drivers this is exactly what the shutdown routine does, so |
2392 |
drivers this is exactly what the shutdown routine does, so |
| 2391 |
if it is included in the driver we can as well just call it. |
2393 |
if it is included in the driver we can just call it. |
| 2392 |
</para> |
2394 |
</para> |
| 2393 |
<para><function>xxx_isa_shutdown(dev);</function></para> |
2395 |
<para><function>xxx_isa_shutdown(dev);</function></para> |
| 2394 |
|
2396 |
|
|
Lines 2416-2422
Link Here
|
| 2416 |
disabling DMA and interrupts in the device registers and |
2418 |
disabling DMA and interrupts in the device registers and |
| 2417 |
stopping any ongoing transfers is a good idea. The exact |
2419 |
stopping any ongoing transfers is a good idea. The exact |
| 2418 |
action depends on the hardware, so we do not consider it here |
2420 |
action depends on the hardware, so we do not consider it here |
| 2419 |
in any details. |
2421 |
in any detail. |
| 2420 |
</para> |
2422 |
</para> |
| 2421 |
</sect1> |
2423 |
</sect1> |
| 2422 |
|
2424 |
|
|
Lines 2426-2442
Link Here
|
| 2426 |
<para> |
2428 |
<para> |
| 2427 |
The interrupt handler is called when an interrupt is |
2429 |
The interrupt handler is called when an interrupt is |
| 2428 |
received which may be from this particular device. The ISA |
2430 |
received which may be from this particular device. The ISA |
| 2429 |
bus does not support interrupt sharing (except some special |
2431 |
bus does not support interrupt sharing (except in some special |
| 2430 |
cases) so in practice if the interrupt handler is called |
2432 |
cases) so in practice if the interrupt handler is called |
| 2431 |
then the interrupt almost for sure came from its |
2433 |
then the interrupt almost for sure came from its |
| 2432 |
device. Still the interrupt handler must poll the device |
2434 |
device. Still, the interrupt handler must poll the device |
| 2433 |
registers and make sure that the interrupt was generated by |
2435 |
registers and make sure that the interrupt was generated by |
| 2434 |
its device. If not it should just return. |
2436 |
its device. If not it should just return. |
| 2435 |
</para> |
2437 |
</para> |
| 2436 |
|
2438 |
|
| 2437 |
<para> |
2439 |
<para> |
| 2438 |
The old convention for the ISA drivers was getting the |
2440 |
The old convention for the ISA drivers was getting the |
| 2439 |
device unit number as an argument. It is obsolete, and the |
2441 |
device unit number as an argument. This is obsolete, and the |
| 2440 |
new drivers receive whatever argument was specified for them |
2442 |
new drivers receive whatever argument was specified for them |
| 2441 |
in the attach routine when calling |
2443 |
in the attach routine when calling |
| 2442 |
<function>bus_setup_intr()</function>. By the new convention |
2444 |
<function>bus_setup_intr()</function>. By the new convention |