The PIC's (PIC16F87XA) firmware can be programmed by an external programmer and have the Flash Program Memory Code Protection bit set or cleared.
How can the firmware check that the protection is enabled?
The configuration word (address 2007h) has a Flash Program Memory Code Protection bit (bit 13).
CP: Flash Program Memory Code Protection bit 1 = Code protection off 0 = All program memory code-protected
The configuration word appears to be inaccessible for writing by the firmware per PIC16F87XA 14.1 Configuration Bits.
It is important to note that address 2007h is beyond the user program memory space which can be accessed only during programming.
As there is no need for the firmware to write the configuration word, loss of write access is not important.
The configuration word also appears to not have read access per the same 14.1.
Is there any way for the firmware to read the Flash Program Memory Code Protection bit, a copy of it, checksum/parity the firmware including the configuration word, somehow assess or test if the firmware is protected?
One can re-connect an external programmer and attempt to read the firmware and either succeed or fail as a test. Yet that is not the firmware itself doing this assessment.
I suspect there is no published solution - I hope I am wrong.