Shop OBEX P1 Docs P2 Docs Learn Events
FYI: COG 0 BOOTER CODE — Parallax Forums

FYI: COG 0 BOOTER CODE

Peter JakackiPeter Jakacki Posts: 10,193
edited 2018-04-27 14:17 in Propeller 2
The other day when in I was in a conference call with Cluso and Chip regarding the boot ROM, out of curiosity I wanted to understand the mechanism inside the P2 before it even calls the ROM code at $FC000 since this ROM is copied into hub RAM and then write protected. Chip pasted a screenshot onto the end of the P2 document of a handful of instructions that are hardwired in cog 0 only that is used to sequentially read the internal non-memory mapped "ROM" into hub RAM and then run it.

The instructions only exists as hardwired 1s and 0s but it helped me to understand how the P2 got to start (but not really start) executing instructions at $FC000 and which mode it was in, which from the listing you can deduce from the coginit. btw, PTRA is hardware preset to $FC000 and PTRB is preset to $4000.
''  wire [15:0][31:0] booti = {
		'' cold boot rom - only cog0 on startup
		wrfast	#0,ptra		' begin write at $FC000 (preset)
		rep 	#1,ptrb		' write $4000 bytes (preset)
		wfbyte	0		' write rom byte to hub ram
		wrfast	#0,ptra 	' finish write
		coginit #0,ptra 	' restart at $FC000
		coginit #0,ptra		' not used
		coginit #0,ptra		' not used
		coginit #0,ptra		' not used

		'' warm boot rom - via coginit
		mov 	outa,#0		' clear port shadow registers
		mov 	outb,#0
		mov 	ina,#$1F8	' point ina/ijmp0 to cog's initial int0 handler
		setq 	#$1F7		' if !hubs, load $1F8 longs from ptrb
		rdlong 	0,ptrb
		jmp 	dirb/ptrb 	' if !hubs, jump to $000 (dirb=0), else ptrb
		jmp 	dirb/ptrb	' not used
		jmp 	dirb/ptrb	' not used
''  };

'' wire [7:0][31:0] debugi = {

		'' debug rom - executes in $001F8..$001FF
		setq	#$0F		' ready to save registers $000..$00F
		wrlong 	0,ptra 		' ptra reads %1111_1111_1ccc_c000_0000
		setq 	#$0F		' ready to load program into $000..$00F
		rdlong 	0,ptrb 		' ptrb reads %1111_1111_1ccc_c100_0000
		jmp 	#0 		' jump to loaded program
		setq 	#$0F		' ready to load program into $000..$00F
		rdlong 	0,ptra 		' ptra reads %1111_1111_1ccc_c000_0000
		reti0 			' calld inb,inb wcz
''  };
1121 x 594 - 26K
Sign In or Register to comment.