9. (16 points) Let the function $f(x)$ satisfy $f\left(2^{x}\right)=x^{2}-2 a x+a^{2}-1$, and $f(x)$ has a range of $[-1,0]$ on $\left[2^{a-1}, 2^{a^{2}-2 a+2}\right]$, find the range of values for $a$.


9. Let $g(x)=f\left(2^{x}\right)$, then $f(x)=g\left(\log _{2} x\right)=\left(\log _{2} x\right)^{2}-2 a \log _{2} x+a^{2}-1$. Therefore, the range of $f(x)$ on the interval $\left[2^{a-1}, 2^{a^{2}-2 a+2}\right]$ being $[-1,0]$ is equivalent to the range of $g(x)=x^{2}-2 a x+a^{2}-1$ on the interval $\left[a-1, a^{2}-2 a+2\right]$ being $[-1,0]$.

Since $g(a)=-1$ is the minimum value of $g(x)$ on $\mathbf{R}$, it follows from the condition that $a \in\left[a-1, a^{2}-2 a+2\right]$, and the maximum value of $g(x)$ on this interval should be reached at the endpoints; also, the function value of $g(x)$ at the left endpoint $g(a-1)=0$ is precisely the maximum value of $g(x)$ on this interval, so $a$ must be in the right half of the interval, i.e.,
$$
\frac{(a-1)+\left(a^{2}-2 a+2\right)}{2} \leqslant a \leqslant a^{2}-2 a+2 .
$$

Solving this, we get $\frac{3-\sqrt{5}}{2} \leqslant a \leqslant 1$ or $2 \leqslant a \leqslant \frac{3+\sqrt{5}}{2}$. Therefore, the range of $a$ is $\left[\frac{3-\sqrt{5}}{2}, 1\right] \cup\left[2, \frac{3+\sqrt{5}}{2}\right]$.