The gemara cites various pesukim as the source for the requirement of hasra'ah (warning). The maharatz chiyus points out that there are two source for hasra'ah. The first is a sevara, is to make sure the person is aware of the severity and consequences of his actions. Included in the hasra'ah is both the education of the halacha, and the awareness of the action that he is about to do. The second source is the pesukim that the gemara quote which serve as a gezeiras hakasuv, whether they apply or not, that no punishment can be carried out unless there is a warning. The maharatz chiyus deduces this from Tosafos who is bothered why the gemara has to find a source for hasra'ah, to which they answer that a non-chaver (someone who isn't educated to know the din) it is obvious from logic that he requires hasra'ah because otherwise he would have no idea whether the action that he is doing is prohibited by the Torah - להבחין בין שוגג למזיד. But, a chaver, who is well educated, knows very well what he is doing and understands the consequences. He shouldn't require hasra'ah if not for the fact that the Torah would demand it as a gezeiras hakasuv. The pesukim is the rationale for requiring the details of hasra'ah such as killing him within תוך כדי דיבור (and perhaps having to accept the hasra'ah).
Based on this, he points out that Tosafos 41a who ask what is the source for hasra'ah by an עיר הנדחת, is difficult. Who says that עיר הנדחת has the gezeiras hakasuv requirement of hasra'ah that would involve the details, perhaps it would only have the sevara aspect of hasra'ah to differentiate between intentional and unintentional, so that no source is necessary. Clearly, tosafos assumes that the type of hasra'ah necessary by עיר הנדחת is the gezeiras hakasuv type with all the details and not just the determination that he was aware of the consequences of his actions.
The Rambam doesn't seem to follow this same approach. The gemara 8b and 41a quote R. Yossi Bar Yehuda who says that a talmid chacham doesn't require hasra'ah since the sole purpose of hasra'ah is to differentiate between shogeig and meizid. This would imply that the Rabbonon who hold that even a talmid chacham requires hasra'ah, would hold that hasra'ah is a gezeiras hakasuv, and NOT just to distinguish between shogeig and meizid. However, the Rambam (Sanhederin 12:2) writes:
אחד תלמיד חכם ואחד עם הארץ צריך התראה, שלא ניתנה התראה אלא להבחין בין שוגג למזיד, שמא שוגג היה
This seems to be very strange. The Rambam cites the rationale of R. Yossi Bar Yehuda, yet requires hasra'ah even for a chaver (talmid chacham). Why? The kesef mishna and lechem mishneh explain that the according to the Rambam, the Rabbonon don't disagree with R. Yossi in principal, rather they hold that because of his concern we require hasra'ah even by a chaver who knows the law, since he may not be aware of the action he is about to do. The Rambam clearly learns that the concept of hasra'ah is only meant to make him aware of his actions, and educate him about the halacha, not just a gezeiras hakasuv. Nevertheless, the Rambam requires hasra'ah within ki'dei dibur of the action, implying that this concept isn't merely a gezeiras hakasuv but an actual concern that he may have a very short term memory. It seems that the Rambam doesn't buy into the 2 sources for hasra'ah approach, rather he understands that the rationale for the sources of hasra'ah cited in the gemara is כדי להבחין בין שוגג למזיד - to educate and inform.