Sun Microsystems CP2500 Write Example Program, Code Example 3-4Write Action on User Flash Device

Page 63

CODE EXAMPLE 3-3Read Action on User Flash Device (Continued)

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_read() {

/* read block 0 of 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();

}

Write Example Program

CODE EXAMPLE 3-4contains the Write Action on the user flash device.

CODE EXAMPLE 3-4Write 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> #include <errno.h> #include <uflash_if.h>

char *uflash0 = "/dev/uflash0";

Chapter 3 User Flash 49

Image 63
Contents Netra CP2500 Board Programming Guide Page Contents User Flash Figures Vi Netra CP2500 Board Programming Guide March Tables Viii Netra CP2500 Board Programming Guide March Code Samples Netra CP2500 Board Programming Guide March How This Book Is Organized PrefaceTypographic Conventions Using Unix CommandsRelated Documentation Shell PromptsDocumentation, Support, and Training Third-Party Web SitesSun Welcomes Your Comments Overview Watchdog TimerPicl Plug-In Module 2Properties Under watchdog-controllerNode 1Watchdog Plug-In Interfaces for Netra CP2500 Board SoftwareHEALTHY# 3Properties Under watchdog-timerNodeCode Example 1-1System Watchdog Node Management Code Example Watchdog Node Management CodeCode Example 1-1System Watchdog Node Management Code Example Usagestr Code Example 1-1System Watchdog Node Management Code Example Code Example 1-1System Watchdog Node Management Code Example Code Example 1-1System Watchdog Node Management Code Example Code Example 1-1System Watchdog Node Management Code Example Code Example 1-1System Watchdog Node Management Code Example Null Code Example 1-1System Watchdog Node Management Code Example Code Example 1-1System Watchdog Node Management Code Example Code Example 1-1System Watchdog Node Management Code Example Code Example 1-1System Watchdog Node Management Code Example Code Example 1-1System Watchdog Node Management Code Example Notreached Code Example 1-1System Watchdog Node Management Code Example OpenBoot Prom Interface Netra CP2500 Board Programming Guide March Environmental Monitoring Environmental Monitoring Component Compatibility Typical Environmental Monitoring System Application1Compatible Environmental Monitoring Components I2C Environmental Monitoring Protection at the OpenBoot Prom Typical Cycle From Power Up to ShutdownPost Shutdown Recovery 3I2C Components Hardware Environmental Monitoring FunctionsEnvironmental Monitoring CPU Inlet, Exhaust, and CPU Temperature Monitoring Switching Power On and OffNetra CP2500 Board Programming Guide March Critical Temperature Response at OpenBoot Prom OpenBoot Prom Environmental MonitoringEnvironmental Monitoring Application Programming Using the show-sensorsCommand at OpenBoot Prom4PICL Temperature Sensor Class Node Properties Reading Temperature Sensor States UsingSolaris Driver Interface Using a Configuration File for Sensor InformationCode Example 2-1Sample envmond Application Program Sample Application ProgramCode Example 2-1Sample envmond Application Program Code Example 2-1Sample envmond Application Program Code Example 2-1Sample envmond Application Program Prtdiag command example Reading the CPU Temperature Environmental Limits5Description of Values Displayed by Solaris Commands User Flash Usage and Implementation User FlashOpenBoot Prom Device Tree and Properties User Flash Driver1User Flash Node Properties 2System Calls Application Programming InterfaceUser Flash Device Files Interface Header FileCode Example 3-1PROM Information Structure Structures to Use in Ioctl ArgumentsErrors Example ProgramsCode Example 3-2User Flash Interface Structure Code Example 3-3Read Action on User Flash Device Read Example ProgramCode Example 3-4Write Action on User Flash Device Write Example ProgramCode Example 3-4Write Action on User Flash Device Code Example 3-5Block Erase Action on User Flash Device Block Erase Example ProgramCode Example 3-5Block Erase Action on User Flash Device Code Example 3-6Sample User Flash Application Program Sample User Flash Application ProgramCode Example 3-6Sample User Flash Application Program Code Example 3-6Sample User Flash Application Program Code Example 3-6Sample User Flash Application Program Code Example 3-6Sample User Flash Application Program Code Example 3-6Sample User Flash Application Program Picl IndexWatchdog-controller, 3 Watchdog-timer, 3