/************************************************************************** * * * this routine reads from the back-up memory the last number of the * * tcp/ip address used from the CPU to regognize "who" it is, i.e. in * * which balcony it is located. * * GdA 15/3/92 * * 28/3/93 : changed ADDRESS * **************************************************************************/ #include #define ADDRESS 0xfffe003c #define PAGE 0x1000 #define ZERO 0x30 #define NINE 0x39 /* main() { int tcp_ip_nr, cpu_nr; char *hv_config[3]; if (get_config( &tcp_ip_nr, &cpu_nr, hv_config) != 0){ printf (" error in get_config \n"); exit (0); } printf (" tcp_ip_nr %d, cpu_nr %d, hv_config %s\n", tcp_ip_nr, cpu_nr, hv_config[cpu_nr]); } */ int get_config(tcp_ip_nr, cpu_nr, hv_config) int *tcp_ip_nr, *cpu_nr; char *hv_config[3]; { char *hv_config0 = "hv_config0"; char *hv_config1 = "hv_config1"; char *hv_config2 = "hv_config2"; char *p, byte; int i; int nr = 0; hv_config[0] = hv_config0; hv_config[1] = hv_config1; hv_config[2] = hv_config2; fpermit ( ADDRESS, PAGE); for ( i = 0; i < 3; i++){ p = (char *) (ADDRESS + i); byte = *p; if (byte < ZERO || byte > NINE){ printf(" get_tcp_ip_nr: wrong code read ( %d ) at ram 0x%x\n", byte, p); exit(0); } nr += ( byte - ZERO) * (int) pow ((double) 10, (double) 2 - i); } fprotect ( ADDRESS, PAGE); *tcp_ip_nr = nr; if ( *tcp_ip_nr == 114 ) *cpu_nr = 0; else if ( *tcp_ip_nr == 121 ) *cpu_nr = 1; else if ( *tcp_ip_nr == 122 ) *cpu_nr = 2; else { exit(_errmsg(0, " wrong tcp/ip number read from backup memory : %d\n", *tcp_ip_nr)); } return 0; }