?? l1_command.c
字號:
int elsc_partition_set(elsc_t *e, int partition){ char msg[BRL1_QSIZE]; /* L1 request/response info */ int subch; /* system controller subchannel used */ int len; /* length of message */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); if( (subch = sc_open( e, L1_ADDR_LOCAL )) < 0 ) { return ELSC_ERROR_CMD_SEND; } if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_PARTITION_SET, 2, L1_ARG_INT, partition )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( sc_command( e, subch, msg, msg, &len ) ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return( 0 );}int elsc_partition_get(elsc_t *e){ char msg[BRL1_QSIZE]; /* L1 request/response info */ int subch; /* system controller subchannel used */ int len; /* length of message */ uint32_t partition_id; /* used to copy partition id out of msg */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); if( (subch = sc_open( e, L1_ADDR_LOCAL )) < 0 ) { return ELSC_ERROR_CMD_SEND; } if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_PARTITION_GET, 0 )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( sc_command( e, subch, msg, msg, &len ) ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 2, L1_ARG_INT, &partition_id ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return( partition_id );}/* * elsc_cons_subch selects the "active" console subchannel for this node * (i.e., the one that will currently receive input) */int elsc_cons_subch(elsc_t *e, uint ch){ char msg[BRL1_QSIZE]; /* L1 request/response info */ int subch; /* system controller subchannel used */ int len; /* length of message */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); subch = sc_open( e, L1_ADDR_LOCAL ); if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_CONS_SUBCH, 2, L1_ARG_INT, ch)) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( SC_COMMAND( e, subch, msg, msg, &len ) ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return 0;}/* * elsc_cons_node should only be executed by one node. It declares to * the system controller that the node from which it is called will be * the owner of the system console. */int elsc_cons_node(elsc_t *e){ char msg[BRL1_QSIZE]; /* L1 request/response info */ int subch; /* system controller subchannel used */ int len; /* length of message */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); subch = sc_open( e, L1_ADDR_LOCAL ); if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_CONS_NODE, 0 )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( SC_COMMAND( e, subch, msg, msg, &len ) ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return 0;} /* elsc_display_line writes up to 12 characters to either the top or bottom * line of the L1 display. line points to a buffer containing the message * to be displayed. The zero-based line number is specified by lnum (so * lnum == 0 specifies the top line and lnum == 1 specifies the bottom). * Lines longer than 12 characters, or line numbers not less than * L1_DISPLAY_LINES, cause elsc_display_line to return an error. */int elsc_display_line(elsc_t *e, char *line, int lnum){ char msg[BRL1_QSIZE]; int subch; /* system controller subchannel used */ int len; /* number of msg buffer bytes used */ /* argument sanity checking */ if( !(lnum < L1_DISPLAY_LINES) ) return( ELSC_ERROR_CMD_ARGS ); if( !(strlen( line ) <= L1_DISPLAY_LINE_LENGTH) ) return( ELSC_ERROR_CMD_ARGS ); /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); subch = sc_open( (l1sc_t *)e, L1_ADDR_LOCAL ); if( (len = sc_construct_msg( (l1sc_t *)e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, (L1_REQ_DISP1+lnum), 2, L1_ARG_ASCII, line )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( SC_COMMAND( (l1sc_t *)e, subch, msg, msg, &len ) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( (l1sc_t *)e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return 0;}/* elsc_display_mesg silently drops message characters beyond the 12th. */int elsc_display_mesg(elsc_t *e, char *chr){ char line[L1_DISPLAY_LINE_LENGTH+1]; int numlines, i; int result; numlines = (strlen( chr ) + L1_DISPLAY_LINE_LENGTH - 1) / L1_DISPLAY_LINE_LENGTH; if( numlines > L1_DISPLAY_LINES ) numlines = L1_DISPLAY_LINES; for( i = 0; i < numlines; i++ ) { strncpy( line, chr, L1_DISPLAY_LINE_LENGTH ); line[L1_DISPLAY_LINE_LENGTH] = '\0'; /* generally we want to leave the first line of the L1 display * alone (so the L1 can manipulate it). If you need to be able * to display to both lines (for debugging purposes), define * L1_DISP_2LINES in irix/kern/ksys/l1.h, or add -DL1_DISP_2LINES * to your 'defs file. */#if defined(L1_DISP_2LINES) if( (result = elsc_display_line( e, line, i )) < 0 )#else if( (result = elsc_display_line( e, line, i+1 )) < 0 )#endif return result; chr += L1_DISPLAY_LINE_LENGTH; } return 0;}int elsc_password_set(elsc_t *e, char *password){ /* shush compiler */ e = e; password = password; /* fill in buffer with the opcode & params; call elsc_command */ return 0;}int elsc_password_get(elsc_t *e, char *password){ /* shush compiler */ e = e; password = password; /* fill in buffer with the opcode & params; call elsc_command */ return 0;}/* * sc_portspeed_get * * retrieve the current portspeed setting for the bedrock II */int sc_portspeed_get(l1sc_t *sc){ char msg[BRL1_QSIZE]; int len; /* length of message being sent */ int subch; /* system controller subchannel used */ int portspeed_a, portspeed_b; /* ioport clock rates */ bzero( msg, BRL1_QSIZE ); subch = sc_open( sc, L1_ADDR_LOCAL ); if( (len = sc_construct_msg( sc, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_PORTSPEED, 0 )) < 0 ) { sc_close( sc, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( sc_command( sc, subch, msg, msg, &len ) < 0 ) { sc_close( sc, subch ); return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( sc, subch ); /* check response */ if( sc_interpret_resp( msg, 4, L1_ARG_INT, &portspeed_a, L1_ARG_INT, &portspeed_b ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } /* for the c-brick, we ignore the portspeed_b value */ return (portspeed_a ? 600 : 400);}/* * elsc_power_query * * To be used after system reset, this command returns 1 if the reset * was the result of a power-on, 0 otherwise. * * The power query status is cleared to 0 after it is read. */int elsc_power_query(elsc_t *e){ e = e; /* shush the compiler */ /* fill in buffer with the opcode & params; call elsc_command */ return 1;}int elsc_rpwr_query(elsc_t *e, int is_master){ /* shush the compiler */ e = e; is_master = is_master; /* fill in buffer with the opcode & params; call elsc_command */ return 0;} /* * elsc_power_down * * Sets up system to shut down in "sec" seconds (or modifies the * shutdown time if one is already in effect). Use 0 to power * down immediately. */int elsc_power_down(elsc_t *e, int sec){ /* shush compiler */ e = e; sec = sec; /* fill in buffer with the opcode & params; call elsc_command */ return 0;}int elsc_system_reset(elsc_t *e){ char msg[BRL1_QSIZE]; int subch; /* system controller subchannel used */ int len; /* number of msg buffer bytes used */ int result; /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); if( (subch = sc_open( e, L1_ADDR_LOCAL )) < 0 ) { return ELSC_ERROR_CMD_SEND; } if( (len = sc_construct_msg( e, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_GENERAL, L1_REQ_RESET, 0 )) < 0 ) { sc_close( e, subch ); return( ELSC_ERROR_CMD_ARGS ); } /* send the request to the L1 */ if( (result = sc_command( e, subch, msg, msg, &len )) ) { sc_close( e, subch ); if( result == SC_NMSG ) { /* timeout is OK. We've sent the reset. Now it's just * a matter of time... */ return( 0 ); } return( ELSC_ERROR_CMD_SEND ); } /* free up subchannel */ sc_close( e, subch ); /* check response */ if( sc_interpret_resp( msg, 0 ) < 0 ) { return( ELSC_ERROR_RESP_FORMAT ); } return 0;}int elsc_power_cycle(elsc_t *e){ /* shush compiler */ e = e; /* fill in buffer with the opcode & params; call sc_command */ return 0;}/* * L1 Support for reading * cbrick uid. */int elsc_nic_get(elsc_t *e, uint64_t *nic, int verbose){ /* this parameter included only for SN0 compatibility */ verbose = verbose; /* We don't go straight to the bedrock/L1 protocol on this one, but let * the eeprom layer prepare the eeprom data as we would like it to * appear to the caller */ return cbrick_uid_get( e->nasid, nic );}int _elsc_hbt(elsc_t *e, int ival, int rdly){ e = e; ival = ival; rdly = rdly; /* fill in buffer with the opcode & params; call elsc_command */ return 0;}/* send a command string to an L1 */int sc_command_interp( l1sc_t *sc, l1addr_t compt, l1addr_t rack, l1addr_t bay, char *cmd ){ char msg[BRL1_QSIZE]; int len; /* length of message being sent */ int subch; /* system controller subchannel used */ l1addr_t target; /* target system controller for command */ /* fill in msg with the opcode & params */ bzero( msg, BRL1_QSIZE ); L1_BUILD_ADDR( &target, compt, rack, bay, 0 ); subch = sc_open( sc, target ); if( (len = sc_construct_msg( sc, subch, msg, BRL1_QSIZE, L1_ADDR_TASK_CMD, L1_REQ_EXEC_CMD, 2, L1_ARG_ASCII, cmd )) < 0 ) { sc_close( sc, subch ); return( ELSC_ERROR_CMD_ARGS ); }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -