~alexeftimie/jockey/fix-gobject

« back to all changes in this revision

Viewing changes to examples/modalias-override-generators/nvidia_supported

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2008-01-17 15:02:40 UTC
  • Revision ID: james.westby@ubuntu.com-20080117150240-djmsi8giu255vzzn
Tags: 0.1~r118
* Initial release, result of completely rewriting restricted-manager to be
  maintainable, robust, and suitable for other distributions. Some features
  and the KDE UI still need to be ported.
* See restricted-manager-rewrite specification for details.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
 
 
3
# Install linux-restricted-modules and binutils, start the script, and put its
 
4
# output to modalias_override/nvidia.
 
5
 
 
6
# This is a nasty kluge, but it seems to work. Better check the output when
 
7
# upgrading to a new release of the nvidia driver, though.
 
8
 
 
9
# Whenever a PCI ID is supported by both nvidia and nvidia_legacy, it is only
 
10
# listed for nvidia.
 
11
 
 
12
echo "# Listing generated by nvidia_supported. Do not edit manually."
 
13
 
 
14
device_ids() {
 
15
        local filename="$1"
 
16
 
 
17
        # Find the first symbol of the .rodata section...
 
18
        objdump --section=.rodata --syms "$filename" |
 
19
        sed -n '/SYMBOL TABLE/,+2 {
 
20
          s/^\([0-9a-f]\+\)\s\+l\s\+O\s\+\S\+\s\+\([0-9a-f]\+\)\s\+\(\S\+\).*/\1 \2 \3/p
 
21
        }' |
 
22
        while read start stop symname; do
 
23
                # ...and grab the IDs from its hex dump.
 
24
                objdump --section=.rodata --full-contents \
 
25
                  --start-address="0x$start" --stop-address="0x$stop" "$filename" |
 
26
                sed -n 's/^ [0-9a-f]\+ \([0-9a-f]\{2\}\)\([0-9a-f]\{2\}\).*/\2\1/p' |
 
27
                sort | uniq
 
28
        done
 
29
}
 
30
 
 
31
set -- "/lib/linux-restricted-modules/$(uname -r)/nvidia/nv-kernel.o" nvidia \
 
32
  "/lib/linux-restricted-modules/$(uname -r)/nvidia_legacy/nv-kernel.o" nvidia_legacy
 
33
 
 
34
seen_ids=' '
 
35
 
 
36
while [ -n "$1" ]; do
 
37
        filename="$1"; shift
 
38
        modname="$1";  shift
 
39
 
 
40
        orig_ids="$(device_ids "$filename")"
 
41
        ids=''
 
42
 
 
43
        for id in $orig_ids; do
 
44
                case "$seen_ids" in
 
45
                *" $id "*)
 
46
                        # Already seen the ID.
 
47
                        ;;
 
48
                *)
 
49
                        # Not seen it yet.
 
50
                        seen_ids="${seen_ids}${id} "
 
51
                        ids="$ids $id"
 
52
                        ;;
 
53
                esac
 
54
        done
 
55
 
 
56
        for id in $ids; do
 
57
                printf "alias pci:v%08Xd%08Xsv*sd*bc03sc*i* %s\n" \
 
58
                  0x10de "0x$id" "$modname"
 
59
        done
 
60
done | sort