Sun Microsystems Netra CP2500 Programming Manual
Sun Microsystems Netra CP2500 Programming Manual

Sun Microsystems Netra CP2500 Programming Manual

For the solaris operating system
Table of Contents

Advertisement

Quick Links

Netra
CP2500 Board
Programming Guide
For the Solaris

Operating System

Sun Microsystems, Inc.
www.sun.com
Part No. 819-1749-11
March 2007, Revision A
Submit comments about this document at:
http://www.sun.com/hwdocs/feedback

Advertisement

Table of Contents
loading

Summary of Contents for Sun Microsystems Netra CP2500

  • Page 1: Operating System

    Netra CP2500 Board ™ Programming Guide ™ For the Solaris Operating System Sun Microsystems, Inc. www.sun.com Part No. 819-1749-11 March 2007, Revision A Submit comments about this document at: http://www.sun.com/hwdocs/feedback...
  • Page 2 Copyright 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é...
  • Page 3: Table Of Contents

    Contents Preface xi Watchdog Timer 1 Overview 1 PICL Plug-In Module 2 Watchdog Node Management Code 5 OpenBoot PROM Interface 21 Environmental Monitoring 23 Environmental Monitoring Component Compatibility 24 Typical Environmental Monitoring System Application 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...
  • Page 4 User Flash User Interface Structure 47 Errors 47 Example Programs 47 Read Example Program 48 Write Example Program 49 Block Erase Example Program 51 Sample User Flash Application Program 53 Index 59 Netra CP2500 Board Programming Guide • March 2007...
  • Page 5 Figures Typical Environmental Monitoring Application Block Diagram 25 FIGURE 2-1 Location of Environmental Monitoring Hardware on the Netra CP2500 Board – Top Side 29 FIGURE 2-2 Netra CP2500 Board Environmental Monitoring Functional Block Diagram 30 FIGURE 2-3...
  • Page 6 Netra CP2500 Board Programming Guide • March 2007...
  • Page 7 Tables Watchdog Plug-In Interfaces for Netra CP2500 Board Software 3 TABLE 1-1 Properties Under watchdog-controller Node 3 TABLE 1-2 Properties Under watchdog-timer Node 4 TABLE 1-3 Compatible Environmental Monitoring Components 24 TABLE 2-1 Typical Netra CP2500 Board Hardware Environmental Monitoring Functions 28...
  • Page 8 Netra CP2500 Board Programming Guide • March 2007...
  • Page 9 Code Samples System Watchdog Node Management Code Example 5 CODE EXAMPLE 1-1 Sample envmond Application Program 37 CODE EXAMPLE 2-1 PROM Information Structure 46 CODE EXAMPLE 3-1 User Flash Interface Structure 47 CODE EXAMPLE 3-2 Read Action on User Flash Device 48 CODE EXAMPLE 3-3 Write Action on User Flash Device 49 CODE EXAMPLE 3-4...
  • Page 10 Netra CP2500 Board Programming Guide • March 2007...
  • Page 11: Preface

    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.
  • Page 12: Typographic Conventions

    Typeface AaBbCc123 AaBbCc123 AaBbCc123 * The settings on your browser might differ from these settings. xii Netra CP2500 Board Programming Guide • March 2007 Meaning The names of commands, files, and directories; on-screen computer output What you type, when contrasted...
  • Page 13: Related Documentation

    Related Documentation Online documents are available at: http://www.sun.com/documentation Title Netra CP2500 Board Release Notes Netra CP2500 Board Installation and Technical Reference Manual Netra CP2500 Board Programming Guide Netra CP2500 Board Safety and Compliance Manual Netra CP2500 Rear Transition Module Installation and...
  • Page 14: Sun Welcomes Your Comments

    You can submit your comments by going to: http://www.sun.com/hwdocs/feedback Please include the title and part number of your document with your feedback: Netra CP2500 Board Programming Guide, part number 819-1749-11 xiv Netra CP2500 Board Programming Guide • March 2007 http://www.sun.com/documentation/ http://www.sun.com/support/ http://www.sun.com/training/...
  • Page 15: Watchdog Timer

    ■ Overview The Netra CP2500 SMC provides two watchdog timers: the watchdog level 2 (WD2) timer and the watchdog level 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.
  • Page 16: Picl Plug-In Module

    Re-arm the watchdog timer. The properties of watchdog-controller and ■ watchdog-timer are defined in 3. Re-enable the primary HEALTHY# signal monitoring on the CPU card in the specified slot. Netra CP2500 Board Programming Guide • March 2007 , and TABLE 1-1 TABLE 1-2 TABLE 1-3...
  • Page 17: Table 1-1 Watchdog Plug-In Interfaces For Netra Cp2500 Board Software

    PICL interfaces for the watchdog plug-in module include the nodes watchdog- controller and watchdog-timer. See descriptions of the properties of these nodes. Watchdog Plug-In Interfaces for Netra CP2500 Board Software TABLE 1-1 PICL Class Property watchdog- WdOp controller watchdog-timer State...
  • Page 18: Table 1-3 Properties Under Watchdog-Timer Node

    :_class watchdog-controller :name watchdog-level1 (watchdog-timer, 26000000536) watchdog-level2 (watchdog-timer, 26000000539) Netra CP2500 Board Programming Guide • March 2007 Description Indicates timer is armed or running. Cleared by Indicates timer has expired. Cleared by Default value set at startup time. Indicates timer is disarmed or stopped.
  • Page 19: Watchdog Node Management Code

    This code can be used to change watchdog timer action and timeout values and also to arm and disarm the watchdog controller. System Watchdog Node Management Code Example CODE EXAMPLE 1-1 * Copyright 2003 Sun Microsystems, Inc. * Use is subject to license terms. #pragma ident "@(#)wdadm.c * This program is used to manage the system watchdog nodes.
  • Page 20 /* watchdog properties */ #define WATCHDOG_ACTION #define WATCHDOG_TIMEOUT #define WATCHDOG_STATUS #define WATCHDOG_OP #define PICL_WATCHDOG_CONTROLLER Netra CP2500 Board Programming Guide • March 2007 "Usage:\n"\ "wdadm - System Watchdog Controller Administration\n"\ - lists all the nodes\n"\ - lists c:t1 and c:t2 nodes\n"\ - controller name\n"\...
  • Page 21 System Watchdog Node Management Code Example (Continued) CODE EXAMPLE 1-1 #define WATCHDOG_DISARMED * data structure that will be passed as argument to * picl_walk_tree_by_class callback function typedef struct { int start_index; int max_index; char **list; char *name; char *action; char *op;...
  • Page 22 /* get the information about the property */ if ((err = picl_get_propinfo_by_name(nodeh, prop_name, return (err); *vbuf = malloc(pinfo.size); if (vbuf == NULL) return (PICL_NOSPACE); Netra CP2500 Board Programming Guide • March 2007 err; proph; &pinfo, &proph)) != PICL_SUCCESS) {...
  • Page 23 System Watchdog Node Management Code Example (Continued) CODE EXAMPLE 1-1 /* read the property value */ if ((err = picl_get_propval(proph, *vbuf, pinfo.size)) != return (err); return (PICL_SUCCESS); * This function is used to set the value of a picl property static picl_errno_t wdadm_set_picl_prop(picl_nodehdl_t nodeh, const char *prop_name, picl_errno_t...
  • Page 24 *args) int err = PICL_SUCCESS; int print = 0, i = 0; Netra CP2500 Board Programming Guide • March 2007 (void **)&timeout) != PICL_SUCCESS) { (void **)&status) != PICL_SUCCESS) { (void **)&action) != PICL_SUCCESS) {...
  • Page 25 System Watchdog Node Management Code Example (Continued) CODE EXAMPLE 1-1 wdadm_args_t picl_nodehdl_t childh, peerh; char cntrl_name[PICL_PROPNAMELEN_MAX]; char wd_name[PICL_PROPNAMELEN_MAX]; char name[2 * PICL_PROPNAMELEN_MAX]; wd_arg = (wdadm_args_t *)args; /* get the controller name */ 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));...
  • Page 26 = &wd_args; err = picl_walk_tree_by_class(rooth, PICL_WATCHDOG_CONTROLLER, (void if (count == 0) { (void) fprintf(stderr, "%s:Node not found:%d\n", return (PICL_NODENOTFOUND); Netra CP2500 Board Programming Guide • March 2007 if (count == 0) { (void) printf("%s", HEADER); count++; (void) printf("%-30s", name); (void) print_watchdog_node_props(peerh);...
  • Page 27 System Watchdog Node Management Code Example (Continued) CODE EXAMPLE 1-1 return (err); * This function is the callback function that gets called * due to picl_walk_tree_by_class call from set_wd_params function. * This function checks if the given controller node has the watchdog-timer * of interest and then changes the timeout and action of that timer.
  • Page 28 = picl_get_propval_by_name(peerh, PICL_PROP_NAME, if (err != PICL_SUCCESS) { /* This code segment changes the watchdog timeout and action */ if (strcmp(ptr, wd_name) == 0) { Netra CP2500 Board Programming Guide • March 2007 prog, picl2errno(PICL_NODENOTFOUND)); (void *)wd_name, PICL_PROPNAMELEN_MAX); print_errmsg(gettext(err_msg[EM_GETPVALBYNAME]), picl_strerror(err));...
  • Page 29 System Watchdog Node Management Code Example (Continued) CODE EXAMPLE 1-1 err = picl_get_propval_by_name(peerh, PICL_PROP_PEER, } 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"...
  • Page 30 (wd_arg == NULL || wd_arg->name == NULL) return (PICL_WALK_TERMINATE); err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, (void *)cntrl_name, PICL_PROPNAMELEN_MAX); if (err != PICL_SUCCESS) { Netra CP2500 Board Programming Guide • March 2007 /* invalid format */ prog, picl2errno(PICL_NODENOTFOUND)); (void) fprintf(stderr, "%s:Illegal timeout value\n", return (PICL_INVALIDARG);...
  • Page 31 System Watchdog Node Management Code Example (Continued) CODE EXAMPLE 1-1 print_errmsg(gettext(err_msg[EM_GETPVALBYNAME]), picl_strerror(err)); return (err); * check to see if the controller is of interest, otherwise * move to the next controller. if (strcmp(cntrl_name, wd_arg->name) != 0) { return (PICL_WALK_CONTINUE); count++; /* change the watchdog-controller’s WdOp property */ if ((err = wdadm_set_picl_prop(nodeh, WATCHDOG_OP, wd_arg->op, strlen(wd_arg->op) + 1)) != PICL_SUCCESS) {...
  • Page 32 ((c = getopt(argc, argv, "hlc:o:m:t:a:")) != EOF) { switch (c) { case ’l’: case ’c’: case ’o’: case ’m’: case ’t’: Netra CP2500 Board Programming Guide • March 2007 err; c, rc = 0; cntrl_name[PICL_CLASSNAMELEN_MAX]; op[PICL_CLASSNAMELEN_MAX]; wd_name[PICL_CLASSNAMELEN_MAX]; timeout[PICL_CLASSNAMELEN_MAX]; action[PICL_CLASSNAMELEN_MAX];...
  • Page 33 System Watchdog Node Management Code Example (Continued) CODE EXAMPLE 1-1 case ’a’: case ’h’: case ’?’: /*FALLTHROUGH*/ default: /* check if more than one action is specified */ if ((lflg + cflg + mflg) > 1) { (void) printf("wdadm: more than one action " usage();...
  • Page 34 (oflg == 0) { rc = control_wd(cntrl_name, op); (void) picl_shutdown(); return (picl2errno(rc)); Netra CP2500 Board Programming Guide • March 2007 * m flag must be associated with atleast * action or timeout (void) printf("wdadm: timeout and action values "...
  • Page 35: Openboot Prom Interface

    There is no user interface to the watchdog timer at the OpenBoot PROM level. When the Netra CP2500 board is in the host slot of a Netra CT 810 or 410 server, the OpenBoot PROM configures the watchdog timer automatically. The watchdog timer is armed only when a boot has been started.
  • Page 36 Netra CP2500 Board Programming Guide • March 2007...
  • Page 37: Environmental Monitoring

    The Netra CP2500 board uses an intelligent fault detection environmental monitoring system that increases uptime and manageability of the board. The system management controller (SMC) module on the Netra CP2500 supports the temperature and voltage environmental monitoring functions. This chapter describes the specific environmental monitoring functions of the Netra CP2500.
  • Page 38: Environmental Monitoring Component Compatibility

    Environmental Monitoring Component Compatibility lists the compatible environmental monitoring hardware, OpenBoot TABLE 2-1 PROM, and Solaris OS for the Netra CP2500. Compatible Environmental Monitoring Components TABLE 2-1 Component Hardware OpenBoot PROM Operating system Typical Environmental Monitoring System Application illustrates the Netra CP2500 environmental monitoring application block FIGURE 2-1 diagram.
  • Page 39 (OEM supplied) node external internal Temp. 1026 voltages System Monitor Temp. sensor Netra CP2500 board Typical Environmental Monitoring Application Block Diagram FIGURE 2-1 Power bus (+5.0 and 3.3 volts) firmware Solaris SMC driver PICL application program (monitor & warn only)
  • Page 40: Typical Cycle From Power Up To Shutdown

    The Netra CP2500 monitors its CPU diode temperature and issues warnings at both the OpenBoot PROM and Solaris OS levels when these environmental readings are out of limits. At the Solaris OS level, the application program monitors and issues warnings for the board. At the OpenBoot PROM level, the CPU diode temperature is monitored.
  • Page 41: Post Shutdown Recovery

    There is no mechanism for the Solaris OS to either recover or restore power to the Netra CP2500 when an unusual condition occurs, for example, if the CPU diode temperature exceeds its maximum recommended level. In either case, the end user must intervene and manually recover the Netra CP2500 as well as the system through hardware control.
  • Page 42: Hardware Environmental Monitoring Functions

    Hardware Environmental Monitoring Functions This section summarizes the hardware environmental monitoring features on the Netra CP2500 board. Netra CP2500 board. Typical Netra CP2500 Board Hardware Environmental Monitoring Functions TABLE 2-2 Function Board Exhaust Air Temperature CPU Diode Temperature Board Inlet Air...
  • Page 43 Location of Environmental Monitoring Hardware on the Netra CP2500 Board – Top Side FIGURE 2-2 is a block diagram of the environmental monitoring functions. FIGURE 2-3 Chapter 2 Environmental Monitoring...
  • Page 44 C controller C MUX Power control and monitor cPCI J5 external I Exhaust ADM 1026 temperature system sensor monitor Inlet temperature sensor Netra CP2500 Board Environmental Monitoring Functional Block Diagram FIGURE 2-3 Netra CP2500 Board Programming Guide • March 2007...
  • Page 45: Switching Power On And Off

    Switching Power On and Off The on-board voltage controller allows power to the CPU of the Netra CP2500 only when the following conditions are met: The VDD core-1.1-volt supply voltage is greater than 1.0 volts (within 10% of ■ nominal).
  • Page 46: Adjusting The Environmental Monitoring Warning, Critical, And Shutdown Parameter Settings On The Board

    These factors might contribute to the sensors reporting different temperature readings than expected. The Netra CP2500 board CPU sensor default temperature threshold values are 110˚C for the high warning temperature, 118˚C for the high shutdown temperature, and 123˚C for the high power-off temperature.
  • Page 47: Openboot Prom Environmental Monitoring

    Note – If you have developed an application that uses the environmental monitoring software to monitor the temperature sensors, you may want to adjust your application’s settings accordingly. OpenBoot PROM Environmental Monitoring This section describes the OpenBoot PROM environmental monitoring of the CPU. Warning Temperature Response at OpenBoot PROM When the CPU diode temperature reaches warning temperature, a similar message is displayed at the ok prompt at a regular interval:...
  • Page 48: Using The Show-Sensors Command At The Openboot Prom

    The system controller device driver must be installed. ■ The environmental monitoring application program (envmond) must be installed ■ and running. Netra CP2500 Board Programming Guide • March 2007 Sensor (d1) Sensor Sensor Sensor...
  • Page 49: Table 2-4 Picl Temperature Sensor Class Node Properties

    The environmental monitoring parameter values in the application program apply when the system is running at the Solaris level and do not necessarily have to be the same as the default settings programmed by the SMC and used by the OpenBoot PROM.
  • Page 50: Using A Configuration File For Sensor Information

    Using a Configuration File for Sensor Information On the Netra CP2500, you can enable or disable sensors, and configure sensor threshold actions, such as shutdown and reboot, by editing the /etc/picl/config/envmond.conf file. Sample entries in the envmond.conf file are: #entry format: name=value option...
  • Page 51: Sample Application Program

    Sample Application Program This section presents a sample environmental monitoring (envmond) application that monitors the CPU diode temperature. Sample envmond Application Program CODE EXAMPLE 2-1 * sensor_readwrite.c * compile: cc sensor_readwrite.c -lthread -lpicl -o sensor_readwrite #include <stdio.h> #include <picl.h> #define HI_POWEROFF_THRESHOLD #define HI_SHUTDOWN_THRESHOLD #define HI_WARNING_THRESHOLD #define LO_POWEROFF_THRESHOLD...
  • Page 52 &threshold, sizeof (threshold)) != PICL_SUCCESS) { fprintf(stderr, "Failed to read low power-off threshold."); } else fprintf(stdout, "Low shutdown threshold = %d\n", threshold); Netra CP2500 Board Programming Guide • March 2007 *resulth = childh; return (PICL_SUCCESS); return (PICL_SUCCESS); &nexth, sizeof (picl_nodehdl_t));...
  • Page 53 Sample envmond Application Program (Continued) CODE EXAMPLE 2-1 if (picl_get_propval_by_name(nodeh, LO_SHUTDOWN_THRESHOLD, &threshold, sizeof (threshold)) != PICL_SUCCESS) { fprintf(stderr, "Failed to read low shutdown threshold."); } else fprintf(stdout, "Low shutdown threshold = %d\n", threshold); if (picl_get_propval_by_name(nodeh, LO_WARNING_THRESHOLD, &threshold, sizeof (threshold)) != PICL_SUCCESS) { fprintf(stderr, "Failed to read low warning threshold.");...
  • Page 54 /* 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); Netra CP2500 Board Programming Guide • March 2007...
  • Page 55: Reading The Cpu Temperature And Environmental Limits

    Reading the CPU Temperature and Environmental Limits You can access the CPU temperature sensor current readings and environmental monitoring settings from the Solaris prompt by typing the following commands. Sample output is listed after each command. prtpicl command example: # prtpicl -c temperature-sensor -v CPU-sensor (temperature-sensor, 2600000041f) :Condition :HighPowerOffThreshold...
  • Page 56: Table 2-5 Description Of Values Displayed By Solaris Commands

    Description of Values Displayed by Solaris Commands TABLE 2-5 Environmental Monitoring Warning The first-level temperature warning is displayed. The second-level temperature warning is displayed. The CPU is shut off. Netra CP2500 Board Programming Guide • March 2007 prtpicl prtdiag HighWarning High Warning Threshold Threshold HighShutdown...
  • Page 57: User Flash

    PROM from the backup copy to get a good OpenBoot PROM image back into the system flash. On a Netra CP2500, the SW3301 dip switch on the board itself can be changed to allow you to boot from the backup copy. Refer to the Netra CP2500...
  • Page 58: Table 3-1 User Flash Node Properties

    Access to the driver is carried out through open, read, write, pread, pwrite and ioctl system interfaces. On the Netra CP2500, one device is supported. There is one logical device file for the physical device that can be accessed from applications. Users can use this device for storing applications and data.
  • Page 59: Table 3-2 System Calls

    User Flash Node Properties (Continued) (Continued) TABLE 3-1 Property Description/Value 00080000 bank-size SUNW,370-xxxx model version number version flashprom name isa-flashprom compatible 00000002 00000000 00100000 User Flash Device Files The user flash device file is /dev/uflash0. Interface (Header) File The user flash header file is located in the following path: /usr/platform/SUNW,Netra-CP2500/include/sys/uflash_if.h Application Programming Interface Access to the user flash device from the Solaris OS is through an application or user...
  • Page 60: Structures To Use In Ioctl Arguments

    /* allow future expansion */ int8_t by driver */ int32_t int32_t } uflash_info_t; Netra CP2500 Board Programming Guide • March 2007 /* identify */ /* query a block */ /* lock a block */ /* clear all locks */ /* erase a block */...
  • Page 61: User Flash User Interface Structure

    User Flash User Interface Structure The user flash user interface structure holds user parameters to commands such as erase. User Flash Interface Structure CODE EXAMPLE 3-2 * uflash user interface structure. typedef struct { uflash_info_t driver */ } uflash_if_t; Errors Application passed one or more incorrect arguments to the system EINVAL call.
  • Page 62: Read Example Program

    (ioctl(ufd0, UIOCIBLK, &ufif0) == -1 ) { perror("ioctl(ufd0, UIOCIBLK): "); exit(1); if (ufd0) { printf("%s: \n", uflash0); printf("manfacturer id = 0x%p\n", ufif0.info.mfr_id); printf("device id = 0x%p\n", ufif0.info.dev_id); Netra CP2500 Board Programming Guide • March 2007 contains the Read Action on the user flash device.
  • Page 63: Write Example Program

    Read Action on User Flash Device (Continued) CODE EXAMPLE 3-3 printf("number of blocks = 0x%p", ufif0.info.blk_num); printf("block size = 0x%p" static int uflash_uninit() { if (ufd0) close(ufd0); cleanup: if (buf0) free(buf0); static int uflash_read() { /* read block 0 of user flash */ if (pread(ufd0, buf0, ufif0.info.blk_size, 0) != ufif0.info.blk_size) perror("uflash0:read");...
  • Page 64 (i = 0; i < ufif0.info.blk_size; i += sizeof(int)) *((int *) (buf0 + i)) = 0xDEADBEEF; /* write block 0 of user flash */ if (pwrite(ufd0, buf0, ufif0.info.blk_size, 0) != ufif0.info.blk_size) perror("uflash0:write"); return(0); Netra CP2500 Board Programming Guide • March 2007 ufif0.info.blk_size);...
  • Page 65: Block Erase Example Program

    Write Action on User Flash Device (Continued) CODE EXAMPLE 3-4 main() { int ret; module = argv[0]; ret = uflash_init(); if (!ret) uflash_write(); uflash_uninit(); Block Erase Example Program CODE EXAMPLE 3-5 Block Erase Action on User Flash Device CODE EXAMPLE 3-5 * uflash_blockerase.c * An example that shows how to erase block(s) of user flash #include <sys/types.h>...
  • Page 66 (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(); Netra CP2500 Board Programming Guide • March 2007 ufif0.info.blk_size);...
  • Page 67: Sample User Flash Application Program

    Sample User Flash Application Program You can use the following program to test the user flash device and driver. This program also demonstrates how this device can be used. Sample User Flash Application Program CODE EXAMPLE 3-6 This application program demonstrates the user program interface to the User Flash PROM driver.
  • Page 68 *devname0 = "/dev/uflash0"; char r_buf = (caddr_t)malloc(PROM_SIZE); w_buf = (caddr_t)malloc(PROM_SIZE); * Open the user flash PROM. Netra CP2500 Board Programming Guide • March 2007 /* returned from pread/pwrite */...
  • Page 69 Sample User Flash Application Program (Continued) CODE EXAMPLE 3-6 if ((fd0 = open(devname0, O_RDWR)) < 0) { fprintf(stderr, "couldn’t open device: %s\n", devname0); exit(1); /* set the default PROM */ prom_id = 0; fd = fd0; /* let them know about the help menu */ fprintf(stderr, "Enter <h>...
  • Page 70 "manufacturer id = 0x%x, device id =\ uflash_if.info.mfr_id & 0xFF, uflash_if.info.dev_id & 0xFF, uflash_if.info.blk_num, uflash_if.info.blk_size); break; Netra CP2500 Board Programming Guide • March 2007 /* lock flash PROM block */ "Enter PROM block number[0, 56]> "); scanf ("%d", &uflash_if.blk_num); goto getout; /* query flash PROM */ "Enter PROM block number[0, 56]>...
  • Page 71 Sample User Flash Application Program (Continued) CODE EXAMPLE 3-6 case ’1’: fprintf(stderr, fprintf(stderr, "Enter number of bytes[hex]> "); scanf ("%x", &size); fprintf(stderr, * init write buffer. for (i = 0; i < size; i++) { w_buf[i] = pat; n_byte = pwrite (fd, w_buf, size, offset); if (n_byte != size) { /* the write failed */ printf ("Write process was failed at byte 0x%x \n",...
  • Page 72 ("\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() */ Netra CP2500 Board Programming Guide • March 2007...
  • Page 73: Index

    Index boot, Solaris OS, 21 commands prtdiag, 41, 42 prtpicl, 4, 35, 41, 42 show-sensors, 34 critical-temperature parameter, 33 device node, 44 dip switch, 43 documentation, related, xiii environmental monitoring, 23 to 42 application block diagram, 24 application program, 34 functional block diagram, 30 temperature monitoring, 32 to 33 envmond application program, 27, 34, 37 to 40...
  • Page 74 file, 45 interface structure, 47 node properties, 44 voltage, 27, 31 voltage controller, 27, 31 warning-temperature parameter, 33 watchdog plug-ins, 3 watchdog timer, 1 to 21 watchdog-controller, 3, 4 watchdog-timer, 3, 4 Netra CP2500 Board Programming Guide • March 2007...

Table of Contents