background image

Chapter 3

User Flash

47

User Flash User Interface Structure

The user flash user interface structure holds user parameters to commands such as

erase

.

Errors

Example Programs

Example programs are provided in this section for the following actions on user
flash device:

Read

CODE EXAMPLE 3-2

User Flash Interface Structure

/*

 * uflash user interface structure.

 */

typedef struct {

        int             blk_num;

        int             num_of_blks;

uflash_info_t

info;

/* to be filled by the

driver */

} uflash_if_t;

EINVAL

Application passed one or more incorrect arguments to the system
call.

EACCESS

Write

or

Erase

operation was attempted on a locked block.

ECANCELLED

A hardware malfunction has been detected. Normally, retrying the
command should fix this problem. If the problem persists, power
cycling the system might be necessary.

ENXIO

This error indicates problems with the driver state. Power cycle of
the system or reinstallation of driver may be necessary.

EFAULT

An error was encountered when copying arguments between the
application and driver (kernel) space.

ENOMEM

System was low on memory when the driver attempted to acquire it.

EBUSY

A

write

operation is already in progress when more than one

write

requests are made.

Содержание Netra CP2500

Страница 1: ...rosystems Inc www sun com Submit comments about this document at http www sun com hwdocs feedback Netra CP2500 Board Programming Guide For the Solaris Operating System Part No 819 1749 11 March 2007 Revision A ...

Страница 2: ...2007 Sun Microsystems Inc 4150 Network Circle Santa Clara Californie 95054 Etats Unis Tous droits réservés Sun Microsystems Inc a les droits de propriété intellectuels relatants à la technologie qui est décrit dans ce document En particulier et sans la limitation ces droits de propriété intellectuels peuvent inclure un ou plus des brevets américains énumérés à http www sun com patents et un ou les...

Страница 3: ...24 Typical Cycle From Power Up to Shutdown 26 Environmental Monitoring Protection at the OpenBoot PROM 26 Environmental Monitoring Protection at the Operating System Level 26 Post Shutdown Recovery 27 Hardware Environmental Monitoring Functions 28 Switching Power On and Off 31 Inlet Exhaust and CPU Temperature Monitoring 31 Adjusting the Environmental Monitoring Warning Critical and Shutdown Param...

Страница 4: ...er Interface 36 Sample Application Program 37 Reading the CPU Temperature and Environmental Limits 41 3 User Flash 43 User Flash Usage and Implementation 43 User Flash Driver 44 OpenBoot PROM Device Tree and Properties 44 User Flash Device Files 45 Interface Header File 45 Application Programming Interface 45 Structures to Use in IOCTL Arguments 46 PROM Information Structure 46 User Flash User Int...

Страница 5: ...Environmental Monitoring Application Block Diagram 25 FIGURE 2 2 Location of Environmental Monitoring Hardware on the Netra CP2500 Board Top Side 29 FIGURE 2 3 Netra CP2500 Board Environmental Monitoring Functional Block Diagram 30 ...

Страница 6: ...vi Netra CP2500 Board Programming Guide March 2007 ...

Страница 7: ...timer Node 4 TABLE 2 1 Compatible Environmental Monitoring Components 24 TABLE 2 2 Typical Netra CP2500 Board Hardware Environmental Monitoring Functions 28 TABLE 2 3 I2C Components 28 TABLE 2 4 PICL Temperature Sensor Class Node Properties 35 TABLE 2 5 Description of Values Displayed by Solaris Commands 42 TABLE 3 1 User Flash Node Properties 44 TABLE 3 2 System Calls 45 ...

Страница 8: ...viii Netra CP2500 Board Programming Guide March 2007 ...

Страница 9: ...ram 37 CODE EXAMPLE 3 1 PROM Information Structure 46 CODE EXAMPLE 3 2 User Flash Interface Structure 47 CODE EXAMPLE 3 3 Read Action on User Flash Device 48 CODE EXAMPLE 3 4 Write Action on User Flash Device 49 CODE EXAMPLE 3 5 Block Erase Action on User Flash Device 51 CODE EXAMPLE 3 6 Sample User Flash Application Program 53 ...

Страница 10: ...x Netra CP2500 Board Programming Guide March 2007 ...

Страница 11: ...y use the information in this document The Netra CP2500 can be used by network equipment providers NEPs and carriers to scale and improve the availability of next generation carrier grade systems The Netra CP2500 functions as a node board in a cPSB system rack or as a CPU board in the Netra CT 810 or 410 cPCI server How This Book Is Organized Chapter 1 provides details on the Netra CP2500 watchdog...

Страница 12: ...n that you received with your system Typographic Conventions Typeface The settings on your browser might differ from these settings Meaning Examples AaBbCc123 The names of commands files and directories on screen computer output Edit your login file Use ls a to list all files You have mail AaBbCc123 What you type when contrasted with on screen computer output su Password AaBbCc123 Book titles new ...

Страница 13: ...hell and Korn shell superuser Title Part Number Netra CP2500 Board Release Notes 819 1748 Netra CP2500 Board Installation and Technical Reference Manual 819 1747 Netra CP2500 Board Programming Guide 819 1749 Netra CP2500 Board Safety and Compliance Manual 819 1750 Netra CP2500 Rear Transition Module Installation and Technical Reference Manual 819 1753 Important Safety Information for Sun Hardware ...

Страница 14: ...leged damage or loss caused by or in connection with the use of or reliance on any such content goods or services that are available on or through such sites or resources Sun Welcomes Your Comments Sun is interested in improving its documentation and welcomes your comments and suggestions You can submit your comments by going to http www sun com hwdocs feedback Please include the title and part nu...

Страница 15: ...evel 1 WD1 timer Management applications for example the Managed Object Hierarchy on the Netra CT 810 410 server or a third party application on a cPSB server start the timers and the Solaris OS periodically pats the timers before they expire If the WD2 timer expires the watchdog function of the WD2 timer forces the SPARC processor to optionally reset The maximum range for WD2 is 255 seconds The W...

Страница 16: ...g timer 1 If the watchdog timer is running stop it by disabling the primary HEALTHY signal monitoring for the CPU card on which the watchdog timer is to be changed 2 In your application use the PICL API to disarm set and arm the active watchdog timer Refer to the picld 1M libpicl 3LIB and libpicltree 3LIB man pages for a complete description of the PICL architecture and programming interface Devel...

Страница 17: ...p Represents a watchdog subsystem watchdog timer State Represents a watchdog timer hardware that belongs to its controller Each timer depends on the status of its peers to be activated or deactivated WdTimeout Timeout for the watchdog timer WdAction Action to be taken after the watchdog expires TABLE 1 2 Properties Under watchdog controller Node Property Operations Description WdOp arm Activates a...

Страница 18: ...c for level 2 Varies by system and timer level Indicates the timer initial countdown value Should be set prior to arming the timer WdAction A specific timer node might not support all action types For example Netra CT watchdog level 1 timer supports only none alarm and reboot actions Watchdog level 2 timer supports only none and reset none Default value No action is taken alarm Sends notifications...

Страница 19: ...t Code Example Copyright 2003 Sun Microsystems Inc All rights reserved Use is subject to license terms pragma ident wdadm c 1 6 03 10 16 SMI This program is used to manage the system watchdog nodes Please refer to libpicl 3LIB for information on picl APIs To compile cc o wdadm lpicl wdadm c include stdio h include stdlib h include stdarg h include string h include strings h include errno h include...

Страница 20: ...s c t1 and c t2 nodes n c1 controller name n t1 timer name n m modify the timeout and action parameters for a timer node n Example n wdadm m c1 t1 t timeout in ms a action n wdadm m c1 t1 t timeout in ms n wdadm m c1 t1 a action n Note Before using this option the controller must be n disarmed using c option n c Execute commands on the watchdog controller node n Commands supported are arm disarm n...

Страница 21: ...ar err_msg program usage USAGE_STR 0 picl call failed messages picl_initialize failed s n 1 picl_get_root failed s n 2 picl_get_propval_by_name failed s n 3 define NUM_ERROR_CODES 7 mapping between picl error codes and errno static int error_map 2 PICL_SUCCESS 0 PICL_FAILURE 1 PICL_VALUETOOBIG E2BIG PICL_NODENOTFOUND ENODEV PICL_PERMDENIED EPERM PICL_NOSPACE ENOMEM PICL_INVALIDARG EINVAL static in...

Страница 22: ...to read picl property The value is copied into vbuf memory allocated for vbuf must be free d by caller static picl_errno_t wdadm_get_picl_prop picl_nodehdl_t nodeh const char prop_name void vbuf picl_errno_t err picl_propinfo_t pinfo picl_prophdl_t proph get the information about the property if err picl_get_propinfo_by_name nodeh prop_name pinfo proph PICL_SUCCESS return err vbuf malloc pinfo siz...

Страница 23: ...fo picl_prophdl_t proph void tmp_buf if err picl_get_propinfo_by_name nodeh prop_name pinfo proph PICL_SUCCESS return err tmp_buf alloca pinfo size if tmp_buf NULL return PICL_NOSPACE if size pinfo size return PICL_VALUETOOBIG bzero tmp_buf pinfo size void memcpy tmp_buf vbuf size set the property value if err picl_set_propval proph vbuf pinfo size PICL_SUCCESS return err return PICL_SUCCESS This ...

Страница 24: ...ON void action PICL_SUCCESS free status free timeout free action return PICL_FAILURE void printf PRINT_FORMAT status action timeout free status free timeout free action return PICL_SUCCESS This function is the callback function that gets called due to picl_walk_tree_by_class call from print_wd_info function This function traveses all the watchdog timer nodes under the given controller and makes a ...

Страница 25: ... PICL_PROP_CHILD childh sizeof picl_nodehdl_t if err PICL_SUCCESS This controller has no childs return PICL_WALK_CONTINUE move to next controller peerh childh traverse thru all the timer nodes using peer property do get the name of watchdog node err picl_get_propval_by_name peerh PICL_PROP_NAME void wd_name PICL_PROPNAMELEN_MAX if err PICL_SUCCESS print_errmsg gettext err_msg EM_GETPVALBYNAME picl...

Страница 26: ...formation of watchdog nodes static int print_wd_info int argc char argv int optind int err PICL_SUCCESS wdadm_args_t args NULL wdadm_args_t wd_args if argc optind print information of all the nodes args NULL else print information of only specified nodes wd_args list argv wd_args start_index optind wd_args max_index argc args wd_args err picl_walk_tree_by_class rooth PICL_WATCHDOG_CONTROLLER void ...

Страница 27: ...dm_args_t wd_arg NULL char status NULL wd_arg wdadm_args_t args if wd_arg NULL wd_arg name NULL return PICL_WALK_TERMINATE get the name of the controller err picl_get_propval_by_name nodeh PICL_PROP_NAME void cntrl_name PICL_PROPNAMELEN_MAX if err PICL_SUCCESS print_errmsg gettext err_msg EM_GETPVALBYNAME picl_strerror err return err name is of cntrl node_name format user input do the parsing to e...

Страница 28: ... childh do get the name of watchdog node err picl_get_propval_by_name peerh PICL_PROP_NAME void wd_name PICL_PROPNAMELEN_MAX if err PICL_SUCCESS print_errmsg gettext err_msg EM_GETPVALBYNAME picl_strerror err return err This code segment changes the watchdog timeout and action if strcmp ptr wd_name 0 if err wdadm_get_picl_prop peerh WATCHDOG_STATUS void status PICL_SUCCESS void free status return ...

Страница 29: ...tting timeout d n prog picl2errno err return err return PICL_WALK_TERMINATE err picl_get_propval_by_name peerh PICL_PROP_PEER peerh sizeof picl_nodehdl_t while err PICL_SUCCESS void fprintf stderr s Node not found d n prog picl2errno PICL_NODENOTFOUND return PICL_NODENOTFOUND This routine gets called to change the watchdog timeout and action wd_name is of controller watchdog timer format static in...

Страница 30: ...cl_walk_tree_by_class rooth PICL_WATCHDOG_CONTROLLER void wd_arg wd_set_params return err This is the callback function that gets called due to picl_walk_tree_by_class function call from control_wd function This function is used to arm disarm the watchdog controller static int wd_change_state picl_nodehdl_t nodeh void arg int err PICL_SUCCESS char cntrl_name PICL_PROPNAMELEN_MAX wdadm_args_t wd_ar...

Страница 31: ...intf stderr s Failed d n prog picl2errno err return err Function is used to disarm arm the watchdog controller static int control_wd char cntrl_name char op wdadm_args_t wd_arg int err PICL_SUCCESS if cntrl_name NULL op NULL void fprintf stderr s Invalid arguments n prog return PICL_INVALIDARG wd_arg name cntrl_name wd_arg op op wd_arg error_code 1 err picl_walk_tree_by_class rooth PICL_WATCHDOG_C...

Страница 32: ... 0 tflg 0 aflg 0 void setlocale LC_ALL if prog strrchr argv 0 NULL prog argv 0 else prog bzero timeout PICL_CLASSNAMELEN_MAX bzero action PICL_CLASSNAMELEN_MAX while c getopt argc argv hlc o m t a EOF switch c case l lflg 1 break case c cflg 1 void strlcpy cntrl_name optarg PICL_CLASSNAMELEN_MAX break case o oflg 1 void strlcpy op optarg PICL_CLASSNAMELEN_MAX break case m mflg 1 void strlcpy wd_na...

Страница 33: ...ne action is specified if lflg cflg mflg 1 void printf wdadm more than one action specified l m c n usage if lflg cflg mflg 0 if no args are specified default action is listing lflg err picl_initialize if err PICL_SUCCESS print_errmsg gettext err_msg EM_INIT picl_strerror err exit 1 err picl_get_root rooth if err PICL_SUCCESS print_errmsg gettext err_msg EM_GETROOT picl_strerror err void picl_shut...

Страница 34: ... or timeout void printf wdadm timeout and action values are missing n void picl_shutdown usage rc set_wd_params wd_name aflg action NULL tflg timeout NULL if cflg if oflg 0 operation must be specified along with c option void printf wdadm operation argument is missing n void picl_shutdown usage rc control_wd cntrl_name op void picl_shutdown return picl2errno rc CODE EXAMPLE 1 1 System Watchdog Nod...

Страница 35: ...imer is armed only when a boot has been started Once the Solaris OS has booted the watchdog timer configuration is changed based on the Solaris OS configuration When the Netra CP2500 board is in a satellite or I O slot of a Netra CT 810 or 410 server or a third party cPSB server the OpenBoot PROM configures the watchdog timer automatically but the timer is not armed when the Solaris OS boots You c...

Страница 36: ...22 Netra CP2500 Board Programming Guide March 2007 ...

Страница 37: ...ic environmental monitoring functions of the Netra CP2500 This chapter includes the following sections Environmental Monitoring Component Compatibility on page 24 Typical Environmental Monitoring System Application on page 24 Typical Cycle From Power Up to Shutdown on page 26 Hardware Environmental Monitoring Functions on page 28 Adjusting the Environmental Monitoring Warning Critical and Shutdown...

Страница 38: ...em Application FIGURE 2 1 illustrates the Netra CP2500 environmental monitoring application block diagram For locations of the temperature sensors see FIGURE 2 2 TABLE 2 1 Compatible Environmental Monitoring Components Component Environmental Monitoring Compatibility Hardware Board supports environmental monitoring OpenBoot PROM Environmental monitoring is supported by OpenBoot PROM Operating syst...

Страница 39: ...rd OEM supplied I2C node Rack midplane PWR PWR PWR MUX I2C internal bus Solaris SMC driver Temp sensor Temp voltages ADM 1026 System Monitor PICL application program monitor warn only Voltage outputs Other boards Power supply OEM supplied Netra CP2500 board I2C external bus Power bus 5 0 and 3 3 volts SMC firmware SMC I2C ...

Страница 40: ...MC and can not be changed for the OpenBoot PROM level monitoring OpenBoot PROM level protection is enabled and can not be disabled If the board temperature exceeds the shutdown temperature the SMC will shut down power to the Netra CP2500 CPU The OpenBoot PROM will send a warning or critical temperature message to the user that the Netra CP2500 is overheating Environmental Monitoring Protection at ...

Страница 41: ...rrant Refer to Sample Application Program on page 37 for an example of how a simple envmond program can be implemented The power module is controlled by the SMC subsystem except for automatic controls such as overcurrent shutdown or voltage regulation The functions controlled are core voltage output level and power sequencing and monitoring Post Shutdown Recovery The on board voltage controller is...

Страница 42: ...e of the board Assumes air direction from the PMC slots toward the processor heatsink CPU Diode Temperature Senses a diode temperature in the processor junction Board Inlet Air Temperature Senses the air temperature at the leading edge of the board under the solder side cover Assumes air direction from the PMC slots toward the processor heatsink TABLE 2 3 I2C Components Component Function DS80CH11...

Страница 43: ...Chapter 2 Environmental Monitoring 29 FIGURE 2 2 Location of Environmental Monitoring Hardware on the Netra CP2500 Board Top Side FIGURE 2 3 is a block diagram of the environmental monitoring functions ...

Страница 44: ...oring Functional Block Diagram PICL application program Solaris SMC driver CPU CPU die temperature sensor Southbridge SMC micro controller PLD I2C MUX cPCI J5 external I2C ADM 1026 system monitor OpenBoot PROM Inlet temperature sensor Exhaust temperature sensor I2C controller Power control and monitor ...

Страница 45: ...assis Care must be taken when setting the alarm and shutdown temperatures based on the CPU diode sensor value This sensor typically is linear across the operating range of the board The exhaust sensor measures the local air temperature at the trailing edge of the board for systems with bottom to top airflow This value depends on the character and volume of the airflow across the board Typical valu...

Страница 46: ...actually reporting the temperature of the area near the sensor For example the CPU diode sensor reads the temperature at the location of the sensor and not on the actual CPU heat sink The board s OpenBoot PROM collects the temperature readings from each board sensor at regular intervals You can display these temperature readings using the show sensors OpenBoot PROM command See Using the show senso...

Страница 47: ...the CPU diode temperature reaches warning temperature a similar message is displayed at the ok prompt at a regular interval Critical Temperature Response at OpenBoot PROM When the CPU diode temperature reaches critical temperature a similar message is displayed at the ok prompt at a regular interval Temperature sensor 2 has threshold event of WARNING Upper Non critical going high The current thres...

Страница 48: ...ons must be met The system controller device driver must be installed The environmental monitoring application program envmond must be installed and running ok show sensors Sensor Sensor Name Sensor Reading 1 EP 5v Sensor d1 4 968 volts 2 EP 3 3v Sensor 8b 3 336 volts 3 BP 12v Sensor ce 11 760 volts 4 BP 12v Sensor 63 12 010 volts 5 IPMB Power Sensor d2 4 968 volts 6 SMC Power Sensor 69 2 448 volt...

Страница 49: ...ased on the information extracted from the IPMI message It then posts a PICL event Threshold levels of the PICL node class temperature sensor are Warning Shutdown Power Off To obtain a reading of temperature sensor states use the prtpicl v command Sample PICL output of temperature sensors on a Netra CT system is as follows TABLE 2 4 PICL Temperature Sensor Class Node Properties Property Type Descr...

Страница 50: ... to local Solaris software This event is captured by the SMC driver as an IPMI message and is sent on an open STREAM that has requested sensor events The sensor events are received by the PICL plug in The PICL plug in updates the State property based on the information it extracts from the IPMI message and posts a PICL event HighShutdownThreshold 118 HighWarningThreshold 110 LowPowerOffThreshold 2...

Страница 51: ...LO_POWEROFF_THRESHOLD LowPowerOffThreshold define LO_SHUTDOWN_THRESHOLD LowShutdownThreshold define LO_WARNING_THRESHOLD LowWarningThreshold define CURRENT_TEMPERATURE Temperature static int get_child_by_name picl_nodehdl_t nodeh char name picl_nodehdl_t resulth picl_nodehdl_t childh picl_nodehdl_t nexth char propname PICL_PROPNAMELEN_MAX picl_errno_t rc look up first child node rc picl_get_propva...

Страница 52: ...printf stdout High power off threshold d n threshold if picl_get_propval_by_name nodeh HI_SHUTDOWN_THRESHOLD threshold sizeof threshold PICL_SUCCESS fprintf stderr Failed to read high shutdown threshold else fprintf stdout High shutdown threshold d n threshold if picl_get_propval_by_name nodeh HI_WARNING_THRESHOLD threshold sizeof threshold PICL_SUCCESS fprintf stderr Failed to read high warning t...

Страница 53: ...dl_t nodeh char threshold int8_t value int8_t new_value value if picl_set_propval_by_name nodeh threshold new_value sizeof new_value PICL_SUCCESS fprintf stderr Failed to set s n threshold int main void int warning_temp int8_t temp char sensor CPU sensor picl_nodehdl_t rooth picl_nodehdl_t platformh picl_nodehdl_t childh if picl_initialize PICL_SUCCESS fprintf stderr Failed to initialise picl n re...

Страница 54: ...get_sensor_thresholds childh Read current sensor temperature if picl_get_propval_by_name childh CURRENT_TEMPERATURE temp sizeof temp PICL_SUCCESS fprintf stderr Failed to read current temperature n else fprintf stdout Current temperature d n temp set_sensor_threshold childh HI_WARNING_THRESHOLD temp 5 picl_shutdown return 0 CODE EXAMPLE 2 1 Sample envmond Application Program Continued ...

Страница 55: ...ure sensor v CPU sensor temperature sensor 2600000041f Condition ok HighPowerOffThreshold 123 HighShutdownThreshold 118 HighWarningThreshold 110 LowPowerOffThreshold 20 LowShutdownThreshold 10 LowWarningThreshold 5 Temperature 74 Label Ambient GeoAddr 0xe _class temperature sensor name CPU sensor prtdiag v CPU Node Temperature Information Temperature Reading 85 Critical Threshold Information High ...

Страница 56: ... the set limit TABLE 2 5 Description of Values Displayed by Solaris Commands Environmental Monitoring Warning prtpicl prtdiag The first level temperature warning is displayed HighWarning Threshold High Warning Threshold The second level temperature warning is displayed HighShutdown Threshold High Shutdown Threshold The CPU is shut off HighPowerOff Threshold High Power Off Threshold ...

Страница 57: ...e for RTOS user data storage and OpenBoot PROM information The Netra CP2500 has a 16Mbyte flash that is logically divided into two parts 2Mbytes for the system boot flash and 14Mbytes for the user flash The main OpenBoot PROM image and a backup copy of the image are stored in the system flash If the OpenBoot PROM is corrupted you can boot the OpenBoot PROM from the backup copy to get a good OpenBo...

Страница 58: ...e device also supports erase and lock features Applications can use them through the IOCTL interface The device is divided into logical blocks Applications that issue these operations also supply a block number or a range of blocks that are a target of these operations Locks are preserved across reboots Locking a block prevents an erase or write operation on that block OpenBoot PROM Device Tree an...

Страница 59: ... C program No command line tool is available User programs open this device file and then issue read write or ioctl commands to use the user flash device The system calls are listed below in TABLE 3 2 bank size 00080000 model SUNW 370 xxxx version version number name flashprom compatible isa flashprom reg 00000002 00000000 00100000 TABLE 3 2 System Calls Call Description read pread Reads device pw...

Страница 60: ...lashIOC 1 query a block define UIOCLBLK uflashIOC 2 lock a block define UIOCCLCK uflashIOC 4 clear all locks define UIOCEBLK uflashIOC 5 erase a block define UIOCMLCK uflashIOC 3 master lock define UIOCEALL uflashIOC 6 erase all unlocked blocks define UIOCEFUL uflashIOC 7 erase full chip CODE EXAMPLE 3 1 PROM Information Structure PROM info structure typedef struct uint16_t mfr_id manufacturer id ...

Страница 61: ...e or more incorrect arguments to the system call EACCESS Write or Erase operation was attempted on a locked block ECANCELLED A hardware malfunction has been detected Normally retrying the command should fix this problem If the problem persists power cycling the system might be necessary ENXIO This error indicates problems with the driver state Power cycle of the system or reinstallation of driver ...

Страница 62: ...stdio h include stdlib h include string h include errno h include uflash_if h char uflash0 dev uflash0 int ufd0 uflash_if_t ufif0 char buf0 char module static int uflash_init char buf0 malloc ufif0 info blk_size if buf0 printf s cannot allocate memory n module return 1 open device if ufd0 open uflash0 O_RDWR 1 perror uflash0 exit 1 get uflash sizes if ioctl ufd0 UIOCIBLK ufif0 1 perror ioctl ufd0 ...

Страница 63: ... user flash if pread ufd0 buf0 ufif0 info blk_size 0 ufif0 info blk_size perror uflash0 read return 0 main int ret module argv 0 ret uflash_init if ret uflash_read uflash_uninit CODE EXAMPLE 3 4 Write Action on User Flash Device uflash_write c An example that shows how to write user flash include sys types h include sys stat h include fcntl h include stdio h include stdlib h include string h inclu...

Страница 64: ...intf s n uflash0 printf manfacturer id 0x p n ufif0 info mfr_id printf device id 0x p n ufif0 info dev_id printf number of blocks 0x p ufif0 info blk_num printf block size 0x p ufif0 info blk_size static int uflash_uninit if ufd0 close ufd0 cleanup if buf0 free buf0 static int uflash_write int i write some pattern to the buffers for i 0 i ufif0 info blk_size i sizeof int int buf0 i 0xDEADBEEF writ...

Страница 65: ...ows how to erase block s of user flash include sys types h include sys stat h include fcntl h include stdio h include stdlib h include string h include errno h include uflash_if h char uflash0 dev uflash0 int ufd0 uflash_if_t ufif0 char module static int uflash_init open device if ufd0 open uflash0 O_RDWR 1 perror uflash0 exit 1 get uflash sizes if ioctl ufd0 UIOCIBLK ufif0 1 perror ioctl ufd0 UIO...

Страница 66: ... static int uflash_uninit if ufd0 close ufd0 static int uflash_blockerase erase 2 blocks starting from block 1 of user flash uf0 blk_num 1 uf0 num_of_blks 2 if ufd0 ioctl ufd0 UIOCEBLK ufif0 1 perror ioctl ufd0 UIOCEBLK return 1 printf nblockerase successful on s n uflash0 return 0 main int ret module argv 0 ret uflash_init if ret uflash_blockerase uflash_uninit CODE EXAMPLE 3 5 Block Erase Action...

Страница 67: ...essed by means of ioctl calls such as identify the chip query block lock block unlock block erase block Please note that not all of the above ioctl calls are available for all flash PROMs It is the user s responsibility to find out the features of a given PROM The type block size and number of blocks of the PROM are returned by identify ioctl The pwrite erases the block s and then does the writing...

Страница 68: ...se blocks q quit h display this menu char get_cmd static char get_cmd char buf 10 gets buf return buf 0 Main main int argc char argv int n_byte returned from pread pwrite int size offset pat int fd0 h i int fd prom_id uflash_if_t uflash_if caddr_t r_buf w_buf char devname0 dev uflash0 char c r_buf caddr_t malloc PROM_SIZE w_buf caddr_t malloc PROM_SIZE Open the user flash PROM CODE EXAMPLE 3 6 Sam...

Страница 69: ...d prom_id switch get_cmd case q goto getout case h case h 0 while help h fprintf stderr s n help h h break case 6 erase flash PROM block fprintf stderr Enter PROM block number 0 56 scanf d uflash_if blk_num fprintf stderr Enter number of block scanf d uflash_if num_of_blks if ioctl fd UIOCEBLK uflash_if 1 goto getout break case 5 clear all locks if ioctl fd UIOCCLCK uflash_if 1 goto getout break C...

Страница 70: ...if blk_num fprintf stderr Enter number of block scanf d uflash_if num_of_blks if ioctl fd UIOCQBLK uflash_if 1 goto getout for i uflash_if blk_num i uflash_if blk_num uflash_if num_of_blks i fprintf stderr block d status x n i uflash_if info blk_status i 0x1 break case 2 identify flash PROM if ioctl fd UIOCIBLK uflash_if 1 goto getout fprintf stderr manufacturer id 0x x device id 0x x n of blks d ...

Страница 71: ...e fd w_buf size offset if n_byte size the write failed printf Write process was failed at byte 0x x n n_byte break case 0 read from user flash PROM fprintf stderr Enter PROM offset 0 0xXX XXXX scanf x offset fprintf stderr Enter number of bytes hex scanf x size getchar clean up the char buf n_byte pread fd r_buf size offset if n_byte size the read failed printf Read process was failed at byte 0x x...

Страница 72: ...ogramming Guide March 2007 printf nuser data buffer n for i 0 i size i printf 2x r_buf i 0xff printf n default continue exit getout close fd0 return end of main CODE EXAMPLE 3 6 Sample User Flash Application Program Continued ...

Страница 73: ...ion program 27 34 37 to 40 envmond conf file 36 I Intelligent Platform Management Interface IPMI commands 27 IOCTL and user flash 45 to 53 M memory 47 O OpenBoot PROM and environmental monitoring 26 and user flash 43 44 and watchdog timer 21 backup copy 43 P PICL man pages 2 temperature sensors 35 watchdog plug in 2 PROM information structure 46 prtdiag command 41 42 prtpicl command 4 35 41 42 R R...

Страница 74: ...evice 45 device files 45 driver 43 header file 45 interface structure 47 node properties 44 V voltage 27 31 voltage controller 27 31 W warning temperature parameter 33 watchdog plug ins 3 watchdog timer 1 to 21 watchdog controller 3 4 watchdog timer 3 4 ...

Отзывы: