home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/puppybasic
-
- include "/usr/lib/wxbasicscript/basefunctions.inc"
-
-
- shell("lspci >/tmp/findhostbridge.tmp")
- pci = readfiletolist("/tmp/findhostbridge.tmp")
- removefile("/tmp/findhostbridge.tmp")
-
- pcihash = {}
-
-
- for i=0 to count(pci)-1
- 'print pci[i]
-
- pci[i]= ucase(pci[i])
-
- if instr( pci[i] , ":") then
- id = cutleft( pci[i] , ": ")
- id = trim(id)
-
- // check for integrated chipsets
-
- if left( id , 4 ) = "10B9" then
- hostbridge = "ali-agp"
- lsmod = "ali_agp"
- shell("modprobe " & hostbridge)
- shell( "lsmod | grep \"^" & lsmod & "\" >/tmp/findhostbridge.tmp")
- isused = readfile("/tmp/findhostbridge.tmp")
- removefile("/tmp/findhostbridge.tmp")
- if right(isused , 1) = "1" then
- print hostbridge
- end
- else
- shell("rmmod " & hostbridge )
- end if
- end if
- if left( id , 4 ) = "1002" then
- hostbridge = "ati-agp"
- lsmod = "ati_agp"
- shell("modprobe " & hostbridge)
- shell( "lsmod | grep \"^" & lsmod & "\" >/tmp/findhostbridge.tmp")
- isused = readfile("/tmp/findhostbridge.tmp")
- removefile("/tmp/findhostbridge.tmp")
- if right(isused , 1) = "1" then
- print hostbridge
- end
- else
- shell("rmmod " & hostbridge )
- end if
- end if
- if left( id , 4 ) = "1039" then
- hostbridge = "sis-agp"
- lsmod = "sis_agp"
- shell("modprobe " & hostbridge)
- shell( "lsmod | grep \"^" & lsmod & "\" >/tmp/findhostbridge.tmp")
- isused = readfile("/tmp/findhostbridge.tmp")
- removefile("/tmp/findhostbridge.tmp")
- if right(isused , 1) = "1" then
- print hostbridge
- end
- else
- shell("rmmod " & hostbridge )
- end if
- end if
- if left( id , 4 ) = "1166" then
- hostbridge = "sworks-agp"
- lsmod = "sworks_agp"
- shell("modprobe " & hostbridge)
- shell( "lsmod | grep \"^" & lsmod & "\" >/tmp/findhostbridge.tmp")
- isused = readfile("/tmp/findhostbridge.tmp")
- removefile("/tmp/findhostbridge.tmp")
- if right(isused , 1) = "1" then
- print hostbridge
- end
- else
- shell("rmmod " & hostbridge )
- end if
- end if
-
- // check for single chipsets
- if instr(id , "(") then
- id = cutright( id , "(" )
- end if
- id = trim(id)
- ' id = replace( id , "8086:" ,"" )
- id = cutleft( id , ":")
- if len(id) = 4 then
- pcihash[id] = id
- 'print pcihash[id]
- end if
- end if
- next
-
- hostbridge = ""
-
- shell("ls /lib/modules/2.6/char/agp/*.ko>/tmp/findhostbridge.tmp")
- modules = readfiletolist("/tmp/findhostbridge.tmp")
- removefile("/tmp/findhostbridge.tmp")
-
- for each module in modules
- if instr(module , "-") then
- if instr(module , "/") then
- module = mycutleftfromright(module , "/")
- module = replace(module , ".ko" , "")
-
- shell("modinfo " & module & " >/tmp/findhostbridge.tmp")
- agp = readfiletolist("/tmp/findhostbridge.tmp")
- removefile("/tmp/findhostbridge.tmp")
-
- for i=0 to count(agp)-1
-
- id = cutleft( agp[i] , "d0000")
- id = left(id , 4)
- if pcihash[id] then
- 'print module & " hostbridge found"
- hostbridge = module
- end if
- 'print id
-
- next
- end if
- end if
- next
-
-
- if hostbridge = "" then
- 'print "no hostbridge found, exiting..."
- else
- 'print "hostbridge found: " & hostbridge
- shell("modprobe " & hostbridge)
- print hostbridge
- end if
-
-
- ////////////////////////////////////////////////////////////////////////////////////
- //
- // return right part of a string, counting the seperator from left
-
- function mycutleftfromright( thestring , splitter )
-
- x = rinstr( thestring , splitter )
- thepath = right( thestring , len(thestring)-x-len(splitter)+1 )
- 'print "---" & thepath
-
- return thepath
-
- end function
-
-