A good way to get started with the kernel source code is to look at version 0.0.1, which can be found here: http://www.kernel.org/pub/linux/kernel/Historic/
volatile void panic(const char * s)
{
printk("Kernel panic: %s\n\r",s);
for(;;);
}In a way, it really isn't much more complicated now. It's changed to take a format string, but beyond that, once you rip out the platform-specific ifdefs, the SMP/lock code, and the automatic reboot code, you're still left with a pretty simple function that does basically the same thing.
[1] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git...