We have developed a semiempirical total-energy functional for silicon-hydrogen interactions in solids. This functional, which is based on a quantum-mechanical analysis, is general enough that it can be applied to a variety of Si-H systems. It contains eight Si-H parameters which are obtained by fitting to bond lengths and vibrational frequencies in SiHn molecules (n=1,2,3,4). As tests of this functional, we have applied it to the calculation of various properties of SiHn and Si2H6 molecules and of the hydrogenated Si(111) surface. Our results are in very good agreement both with experiment and with first-principles calculations. Our Si-H functional and the associated parameters thus show promise for application to other silicon-hydrogen systems.