Annotation of researchv9/jerq/src/lib/sys/bram.c, revision 1.1.1.1

1.1       root        1: #include <setup.h>
                      2: #include <jerq.h>
                      3: #include <font.h>
                      4: #define ESC    '\033'
                      5: #define        BRAM_SIZE       2048    /* size of BRAM in bytes */
                      6: 
                      7: checkbram()    /* return 1 if bram has valid checksum.  If not, clear */
                      8:                /* the battery backed ram, putting in a valid checksum */
                      9: {
                     10:        register long i = 0;
                     11:        register int j;
                     12: 
                     13:        for (j=0; j<BRAM_SIZE - 2; j++)
                     14:                i += BRAM->opts.opt_array[j].byte;
                     15:        j =  (BRAM->opts.opt_array[BRAM_SIZE - 2].byte << 8) + 
                     16:                BRAM->opts.opt_array[BRAM_SIZE - 1].byte;
                     17:        i %= (1 << 16);         /* truncate to checksum size */
                     18:        if ( i == j)
                     19:                return(1);
                     20:        for (i=0; i<BRAM_SIZE; i++)
                     21:                BRAM->opts.opt_array[i].byte = (unsigned char) 0;
                     22: /*     for (i=0; i<8; i++)                                             */
                     23: /*     {                                                               */
                     24: /*             BRAM->pfkeys[i][0].byte = (unsigned char) ESC;          */
                     25: /*             BRAM->pfkeys[i][1].byte = (unsigned char) '0';          */
                     26: /*             BRAM->pfkeys[i][2].byte = (unsigned char) ('c' + i);    */
                     27: /*     }                                                               */
                     28: /*     THIS is how to implement ansi std default pfkeys                */
                     29: 
                     30:        return(0);
                     31: }
                     32: 
                     33: setbram()      /* reset checksum in bram... done when bram updated */
                     34: {
                     35:        register long i = 0;
                     36:        register int j;
                     37: 
                     38:        for (j=0; j<BRAM_SIZE - 2; j++)
                     39:                i += BRAM->opts.opt_array[j].byte;
                     40:        BRAM->opts.opt_array[BRAM_SIZE - 1].byte = i & 0xff;
                     41:        BRAM->opts.opt_array[BRAM_SIZE - 2].byte = (i >> 8) & 0xff;
                     42: }
                     43: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.